Where is the LightSwitch internal database? - database

I've just downloaded VS LightSwitch and I'm doing a sample application for myself. I have created a new table by using Create new table option and have inserted some data. So after I inserted 3 records, the ID is obviously showing 3, which is correct.
Now I want to truncate the data from the table.
My question is, where is the internal table or the internal database (ApplicationData) ?
Thanks

The following steps worked for me:
From the solution folder of your sample application, open the
bin\data folder
You should see the ApplicationDatabase.mdf file
Open SQL Server Management Studio
Use the attach functionality to open the mdf file
After making your changes, detach it

It seems that LightSwitch uses SQL Server Express for its internal database. Try looking in the bin\data folder of your project for an ApplicationDatabase.mdf file.

From the official "Working with SQL Server LocalDB in LightSwitch Projects in Visual Studio 2012" (emphasis mine):
"When you create new tables, LightSwitch automatically creates them in the internal database, also known as the Intrinsic database or ApplicationData. In the first version of LightSwitch in Visual Studio 2010 we used SQL 2008 Express for the internal database development. Now with LightSwitch in Visual Studio 2012 we are using SQL Server LocalDB. (Note: LocalDB is only used during development time. When you deploy your app you can choose to deploy to any version of SQL Server.) LocalDB is the new version of SQL Server Express that has a much lower memory footprint and is targeted for developers. It is installed automatically when you install Visual Studio 11. "

Related

Is Microsoft dropping support for SDF database files in Visual Studio?

In Visual Studio 2013 there is no longer an option to create .sdf SQL Server Compact databases in WebPages (WebMatrix) websites. I am no longer able to view .sdf database files in Visual Studio either. I downloaded the latest version of WebMatrix to open my .sdf database but WebMatrix crashes when I open my website. When I create a new empty site and add existing files, it crashes.
I searched for days for a way to view and edit my .sdf database and nothing is working. I can no longer get Navicat SQL Server app to open a database. I cannot get LinqPad to open an .sdf database file, I cannot get Compact Viewer to open or edit .sdf databases. I can open .sdf databases with SqlCEToolbox40.exe but it only shows top 200 rows and it won't let me edit the tables.
Now I'm completely stumped. How do I view and edit a .sdf database file?
The answer is yes: Microsoft is silently dropping support (as usual IMHO) to Sql Compact Edition.
It started abandoning Sql CE 3.5 in Vs2012
It continued dropping Sql CE in Sql Management Studio 2012
and finally in VS2013
You can use CompactView or install SQL Server Compact Toolbox extension in VS2013 or (my prefered solution) use Sql management Studio 2008
UPDATE thanks to Nicolas' comment
As stated by Microsoft:
SQL Server compact edition is in deprecation mode with no new releases
planned near future. Last release SQL CE 4.0SP1 (and earlier releases
that are still in the support cycle) will continue to be supported
through its lifecycle and Microsoft is committed to fix any major,
production blocking issues found in these releases.

How to migrate a Visual Studio 2012 ASP.Net MVC 4 project to use an SQL Server instance instead of a data file?

When I create a new ASP.Net MVC 4 project with Visual Studio 2012 it puts the data in an mdf file in the project directory.
What I would like to do at this point is to migrate the database to an SQL Server instance gently, keeping all the scaffold stuff provided by the ASP.Net MVC 4 project template (I mean user accounts management etc.)
What would be the right step-by-step way to do this?
How exactly should I change the connection string?
How should I authentify my application in SQL Server in production?
Sorry for a dumb question but I haven't dealt with ASP.Net applications before, in my previous experience (which was with WinForms) all the actual users had a separate SQL Server account and it was pretty straightforward.
The whole User Instance and AttachDbFileName= approach is flawed - at best! Visual Studio will be copying around the .mdf file and most likely, your INSERT works just fine - but you're just looking at the wrong .mdf file in the end!
The real solution in my opinion would be to
install SQL Server - Express (and you've already done that anyway) or any other edition
install SQL Server Management Studio (Express)
create your database in SSMS Express, give it a logical name (e.g. YourDatabase)
connect to it using its logical database name (given when you create it on the server) - and don't mess around with physical database files and user instances. In that case, your connection string would be something like:
Data Source=.\\SQLEXPRESS;Database=YourDatabase;User ID=AppUser;Pwd=Top$ecret
and everything else is exactly the same as before...
For deployment to production, you basically have a number of options:
create deployment SQL scripts yourself and have them executed using sqlcmd or any other useful SQL script runner
use a SQL diff tool like Red-Gate SQL Compare or even the built-in Visual Studio diff tool to determine difference between the database version installed at your client's site, and the new version, and create a single upgrade SQL script from that diff
use the Visual Studio Database Projects and let VS handle the upgrade scripts and deployments. VS database projects craft a model on top of your database - you basically only ever create the CREATE TABLE .... script and the VS tools figure out what needs to be altered, dropped, created fresh
if you're using Entity Framework code-first - look into using the EF code-first migrations to update your database from C# code
What I did is just move the mdf and log file and attach them via SQL Server management studio
The connectstring can be quite simple, something like:
<add name="DefaultConnection" connectionString="Server=YourServer;Initial Catalog=YourDatabaseName;Integrated Security=SSPI;" providerName="System.Data.SqlClient" />

SSDT Not Working In Visual Studio 2010 SP1

I'm running Visual Studio 2010 SP1 Premium on Windows 7, and am trying to create SQL Server Reporting Services (SSRS) Reports. I've downloaded the new SQL Server Data Tools (SSDT) from http://msdn.microsoft.com/en-us/data/hh297027 and installed/restarted. If I go into VS Help->About, I can see "Microsoft SQL Server Data Tools 10.3.20225.0" in the list of installed products. However, SSDT doesn't seem to be showing up in the "New Project" window, and if I try to open existing SSRS 2005 reports projects (created in BIDS/VS 2005) it says "'Reports.rptproj' cannot be opened because its project type (.rptproj) is not supported by this version of the application. To open it, please use a version that supports this type of project".
Am I incorrect in my impression that VS/SSDT does not require SQL Server being installed? Is there some other software, package, or step that I'm missing in installing SSDT?
For SQL Server 2012 SSRS, the functionality of BIDS is REPLACED by SSDT. If you are working with SQL Server 2008 R2 (or earlier) SSRS, then you'll want to use BIDS from that version of SQL Server.
When you install SSDT, it includes templates for BI projects (i.e. SSAS, SSIS, SSRS). SSDT can be installed as a stand-alone application, or, if you have VS2010 SP1 on your machine, then SSDT will install inside of VS2010.
For the OLTP (including offline) database projects, there is NO template. Rather there is a new View named 'SQL Server Object Explorer'. For more about the latter, see my blog post.
The new project type is found under Other Languages->SQL Server-> SQL Sever Database Project.
Do not confuse that with the old to be deprecated projects under Database->SQL Server->Advanced
The BIDS part of SSDT is sort of a separate install. (although they've tried making it seem like one install.) See this on information about why one or the other might not be installed:
http://www.jamesserra.com/archive/2012/04/ssdt-installation-confusion/

How do I create/add a sql server compact edition db in vs2010?

I have vs2010 ultimate installed and sql server 2008 developer. I created a package using the openAuth Extension from the online gallery and can not find an option to add a sql server CE db to my project. I tried changing the target framework to 4.0 and still nothing.
I see a type that says SQL Server Database, but I believed that was for a full blown db to attach to sql server.
Where is compact?
You first need to add it in the Server explorer even if it's new.
Here is the link on how to do it.
link text
If you mean to this:
http://i.imgur.com/NcmH1.png
I fix my problem running SSCEVSTools-esn.msi from the vs2010 dvd.
D:\Visual Studio 2010\WCU\SSCE

How do you work with SQL Server CE and SQL Server 2008 Express?

I have installed:
Visual C# 2008 Express
Visual Web Developer 2008 Express
Visual Studio 2008
SQL Server 2008 Express
SQL Server Management Studio
In Visual C# 2008 Express, I can "Add Item" and create a "Local Database" (.sdf file) or a "Service Based Database" (.mdf file).
Visual Studio 2008 is the same as Visual C# 2008 for applications but in Websites, the only way I can create .sdf or .mdf files is via the Database Explorer.
In Visual Web Developer 2008 Express, however, I can "Add Item" and ONLY create a "SQL Server Database" (.mdf file). Even the Database Explorer doesn't offer to create a SQL CE database.
Questions:
why the discrepency between the applications, is this normal or did something go wrong with my installations?
I never "installed SQL CE", where did it come from and how is it that I am able to create .sdf file?
How do you work with these in projects on a day to day basis, do you use Visual Studio to edit the databases or do you use SQL Server Management Studio?
I believe only Professional and above may create MSSQL CE databases.
SQL CE is installed with 2008 studio, I was surprised to see it myself and didn't see an option to exclude it.
Personally I use VS 2008 to add items to my project databases. Since it's open anyway I just use it. It provides most of the same functionality as Management Studio. If I am doing separate database work, I usually do it in Management studio.
The CE databases are pretty useless. They have a limited sub-set of types and functions. They do not support views or stored procedures. Basically they only store tables; I haven't attempted to create foreign keys in them.
There is no way to rename tables or columns. You must create a new table.
Once you create your database it must be manually added to your project.
You cannot directly create a LINQ to SQL class in VS2008 on a CE database. You need to use the command line tool sqlmetal (called from .NET console) to create the class for you.
I've had issues where the Class created for a CE database didn't work like a class built for a regular SQL database. Because of this I abandoned using a CE database all together.
It would be nice if there was a reliable way to use Linq to SQL on SQLite databases. SQLite is a great self-contained database not requiring any type of external engine.
Sorry I don't have any performance statistics for an SQL CE database.
I hope this is somewhat helpful.
Brett
Ok registered now and not sure why got a -1 vote on previous answer but will expand.
Web Developer Express 2008 Does not create or work with Sql Server CE simply because SQL Server CE is not designed to work on the Web Server.
When you load c# express or vb express. sql server express 2008 is offered to be installed. SQL CE isn't installed. if you go and add a data source the two I know will be there, Microsoft SQL Server Compact 3.5 (.NET Framework Data Provider for Microsoft SQL Server Compact 3.5)and Microsoft SQL Server Database File (SqlClient), the access client may be there also.
It should be noted with a default Express setup that if you choose to use the data provider for sql server compact it will fail even though it is an option. you would have to download sql server ce separately to create sdf databases.
Also Express versions are targeted to a different audience and doesn't have the same ui setup as the main vs sku's have. For example Web express in database setup doesn't even offer the choice to use sql server ce. while in VS it is a choice from the data menu mainly because VS supports more than just web developer.
Now you said you loaded VS 2008 (didn't say what version but doesn't matter since this affects standard and above)
The default install for vs 2008 will install Sql server ce (and as previous answer stated 3.1 was with rtm, 3.5 was with sp1). you can turn it off in advance options.
One concern I have is that you mention that you can't create a database in vs on web projects. which template are you using. You should be able to create server based database Items in add item and both local and server database objects in the data tab.
so in Summery.
on client based express skus and client based projects you should be able to create a local or server based database from add item and from the data tab.
Since sql CE is not officially supported on the Web Server. on the web skus in add Item you should only have access to create a server based database. on express since it is a dedicated sku CE isn't an option in either the data tab or the add item. on vs you can create a CE database from the Data tab. and you should have access to create a server database in add item.
sql server management studio doesn't care where the source is. so it will work with all and create the database.
I use all the options listed just depending on what or where I am at the time. as was mentioned CE on the desktop is primarily a cache database perfect for offline database support. but does have its limitations and in addition really needs better integration. once I am created or working with a database in support I primarily use management studio.
The key point in why you can't access CE from Web express is that CE is not supported on the web server.
Douglas
This is normal. The database types supported by the Visual Studio designer differ by edition. Note that any version of Visual Studio can write and use code that connects to any of those databases. It's just that the visual "wizard" tools included with the IDE that walk you through it are different for each edition.
SQL CE is the Compact Edition of sql server. It's intended for use on portable devices like smart phones or as an Access replacement for a local data store in desktop apps. It's very portable: only 2 dlls that clock in at less than 1Mb of disk space, and was probably included with at least one of your Visual Studio packages, probably all of them.
I normally do all my database work from Management Studio, but that's a personal preference.
The discrepancy is odd, but since SQL CE is a plugged-in item, it may well be that the team didn't test every possible scenario and some of the applications simply didn't get the info they needed to know that it's there. I'm not saying that anything went wrong - it may simply be a scenario that the SQL CE team never tested.
SQL CE was installed with Studio (can't recall offhand, but I think 3.1 shipped with the RTM and 3.5 shipped with SP1).
I always use Management Studio for making database modifications (except those done directly in code).

Resources