Reload database objects in a VS database project? - visual-studio-2010

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.

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.

Import all objects from Oracle to Visual Studio Database Project

I have a Oracle database to which I connect from Visual Studio 2010 (Oracle Developer Tools). I now have the database in the "Server Explorer" window and can see all Tables, Views, Functions, etc.
Now I want to have all those objects in my database project solution (I want to use the version control of TFS, that's the reason I want all objects in my solution). I can right click a single function and choose "Generate Create Script to Project", then it will do exactly what I want, it creates a new script in the "Functions" folder of the database project, with the same name as the function.
Problem:
If I select two or more functions and use the "Generate Create Script to Project" function, then I have to choose a name for the script and it will write all the functions in one script. But I want a single file per script.
Question:
Is it somehow possible to export all objects from the oracle database and import them as script in the Visual Studio database project?
If I use a different driver (devart), then I am able to do it, but we want to use the ODT and I couldn't find an easy way to complete that task there.
Edit: Just noticed, that the devart project is not compatible with source control, so we absolutely have to go with ODT.

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.

Visual Studio 2010 - Database Projects (where are the project template for just script files?)

VS.NET 2010 removed the database project template that could be used for just script files
(that you right click on and execute on desired database).
I want to add a database project similar to the ones in VS.NET 2008? Can i do this?
I tried to use one of the new vs.net 2010 database projects however, in our environment we have multiple applications within the same database. We also have a lot of legacy stuff. In addition we have a lot of queries that cross databases (i.e. in the case of accessing data wharehouse tables). It sure seems that this scenario is hard to use with the new database projects. It seems this adds a lot of complexity to using the new db projects.
What sort of database project is best to be used for this scenario??

Resources