Lightswitch 2013 linked SQL Database Project disabled - visual-studio-2013

OK, after lots of searching I've boiled this down to an extremely simple repro and am very confused. I have VS 2013, all updates, etc.
Create new HTML Lightswitch app, creates 3 projects.
Add new database project to solution
Go to Lightswitch properties (of "common" project)
Result: SQL Database Project drop down is disabled and set to .
Expected: My new db project to be listed for me to link.

You must create at least one table in the Intrinsic Database before you can choose an SQL Database Project to link to your LightSwitch Project. That is, right-click "Data Sources" and choose "Add Table".
From http://blogs.msdn.com/b/lightswitch/archive/2013/07/03/intrinsic-database-management-with-database-projects-chris-rummel.aspx:
The last step to using the database project is to let LightSwitch know
about it. Open the LightSwitch project properties and select your
database project.
Note that you won’t be able to select a database project if you don’t
have any intrinsic tables, so if you’re trying this out in a new
project you’ll have to create a table first.

Related

How do I import the subset of a database into a visual studio 2013 project

I'm trying to upgrade a Visual Studio 2008 database project to a visual studio 2013 database project.
I've been getting an error like
[dbo].[trigger_name] has an unresolved reference to object [dbo].[table_name]
From what I've read here, it seems to say that you can import a subset of a database somehow:
SQL Server Database projects are meant to mirror fully the databases
to which their contents will be deployed. Although you can create
projects that contain just a subset of a database—for example, the
assets for a SQL CLR assembly—SSDT will block you as soon as any T-SQL
in the project references an object in the database that is not also
in your project.
Since I only need 10 tables for my script to run, how do I create these tables in my project, so that I no longer encounter the aforementioned error?
Or, is there a way to link to a database on a server and allow my triggers to verify the object against the actual database schema?
You can create a new db project then right click on it and choose Import database. In
the Import wizard you will choose which table you want to be imported.
Once you have it imported then go to your actual database project and add database reference which will point to the newly created project.
Second method is to add those 10 tables to your existing project. Right click on the project name and choose Schema Compare. Set your project as a target and Sql Server database as a source, click Compare, choose your tables and click Update target.
You can't add a reference to sql server directly.

Database Schema Viewer functionality in vs2013

Recently migrated from vs 2010 -> vs 2013. Observed that there is no Database Schema Viewer in vs 2013 for DB projects. SQL Server Explorer does something similar but when you add new items (say a new table) to a project, noticed two things:
1. the new table file gets created in the root folder and not under the Schema Objects\Schemas\dbo\tables\
2. In vs2010, the table scripts used to have extension XX.table.sql but in vs2013, its always XX.sql
What actions can i take to achieve the above 2 behaviors as in vs 2010
Schema View is no longer part of Visual Studio. You'll have to use a 3rd party tool. If you have SQL Server Management Studio then you can use its database diagrams feature.
Visual Studio no longer manages the folder structure in database projects. When adding a new item, you should add it to the appropriate folder yourself.
To include the schema name in your files go to the database project's properties, select the Project Settings tab, and check Include schema name in file name. This change is not retroactive.

Reload database objects in a VS database project?

if I create a SQL Server 2008 Database Project in Visual Studio 2010, then I am able to right click the project and select Import Database Objects and Settings.... I can do that exactly one time (even if I get an error while importing). If I did it one time, the option is grayed-out.
But after I have imported my objects, I couldn't find a way to reload or refresh the objects. A good example would be, that I have a database project of a whole database and someone adds something to the database directly. Now I want to have new table (function, procedure, etc.) in my project, too.
There has to be a better way than copy&paste to add new existing database objects to my database project?
I found this question:
Script all SQL database objects into VS Database project
But I neither have a Schema Compare option, nor can I drag&drop files from the server explorer.
In Visual Studio you should see a menu choice that says Data. If you click on that, you should be able to run a Schema Compare. If you're not seeing that, then there's something wrong with your VS install or the project or maybe both.

Database in version control using Visual Studio 2010 Professional

I've added a SQL Server 2008 database project to my Visual Studio 2010 Professional Edition solution in the hope that it might allow me to include my database in version control.
I can commit the schema files for each database object into version control, however these schema files all script objects as create rather than alter, so are not good for colleges getting my changes and updating their databases.
Is this a good way to get my database into source control?
And what would the workflow be for actually using it to update databases to a given revision without losing all the data associated with dropping and re-creating all the tables?
Update: on Premium and Ultimate versions, there is a schema compare tool which makes this easy. This does not exist on Professional. Is there any straightforward manual workaround?
I'm not sure if you can do this in VS 2010 Professional, but in VS 2010 Premium, you can do a schema comparison (Data -> Schema Compare -> New Schema Comparison) between your project and database, and update changes in either direction.
When going from project to database, VS generates a script that copies existing data into a temporary table before dropping the existing one.
The database project has a deploy step (which is present in my Professional copy of VS2010) that will generate a sql script with your sql objects in it.
The key thing here is if you r-click the project, properties, goto deploy and change target database settings to a specific database, when you deploy it will generate a change script for that specific database so it matches the objects in the project (and in theory keep existing data etc).
You can get it to either generate a sql script, or directly update the database. Generating a script is probably a better idea :)

Accessing Visual Studio Database Project Schema Programatically

I'm trying to find a way to access the schema of a database project programatically from within Visual Studio 2010.
For example, if I have a solution containing a SQL Server Database Project which defines tables, views etc, and Visual Studio displays those objects within the schema view, I'd like to be able to enumerate the objects in the schema view.
Can anyone provide some tips or a link? Thanks.
Here is a starting point on MSDN. The "Create Custom Features for Database Projects" part is probably relevant for you.

Resources