Import all objects from Oracle to Visual Studio Database Project - visual-studio-2010

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.

Related

How to save a SQL Server Maintenance Plan within a Visual Studio Database Project

Having created a SQL Server maintenance plan in a SQL Server 2008 R2 instance, how can I import the definitions into a Visual Studio 2013 SSDT database project?
I don't mind using pre- and post-deployment scripts if that helps but I want it to be in a database project and to be able to build the project in VS and then to be able to deploy either a new instance of the plan, or to be able to synchronize an existing plan instance with the definitions in the database project. Also, drop and re-create is entirely acceptable.
Does anyone else already know how to do that ?
First of all maintenance plans are not supported by SSDT.
You can export it manually as an xml template file and then try to write some sql/batch post deploy scripts to deploy it.
You can find general instruction here (read comments also): https://robertbigec.wordpress.com/2013/10/03/automating-deployment-of-sql-server-maintenance-plans/
One note: The exported xml template contains some specific values such as server name or path to backup/log file locations. You might want to write custom script to get these values from target machine and replace it in the xml file.

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.

Using Oracle Developer Tools with Source Control for Visual Studio

I'm a bit lost in implmementing/using tfs version control with Oracle products. The project I'm on is using visual studio 2012, tfs 2013, an oracle 11g server, a few copies of Oracle SQL Developer, and a few copies of toad.
I was recently looking for a way to do tfs version control through visual studio using oracle developer tools*. Is this a viable approach?
When tooling around with it, I've been able to create a database project with tables, procs, etc and put this under tfs version control. I've also been able to run these procs against my normal database server. However, I have not been able to put my existing database under version control. I have also not been able to run my code against the visual studio database project.
So can tfs be used with oracle developer tools to provide a version control solution?
Alternatively, are there any ways to integrate tfs version control with both Oracle SQL develoeper and toad?
*Oracle Developer Tools - http://www.oracle.com/technetwork/developer-tools/visual-studio/overview/index-097110.html
On the oracle developer tools promo page it says
"SQL Script Lifecycle with Source Control Integration: Generate SQL
scripts for Oracle schema objects that your .NET application uses,
manage them in an Oracle Database Project, check them into source
control, edit the scripts in the Oracle SQL Editor, and execute them
with a built in SQL*Plus execution engine."
How does this work? Can I automatically generate the scripts each night and check them in or something?
Yes, after you install Oracle Developer Tools for Visual Studio, you can configure your Oracle Data Connections in the Server Explorer, create a new Oracle Database Project, then drag and drop packages or other items from the Server Explorer to your new project. Then, after editing the .sql files that were generated, you can right-click on the .sql files generated and "Run" or "Run on...". Finally, you can also run subsets of each script by right-clicking on a selection and choosing "Run selection".
You still need the discipline to ensure everyone edits packages via source control and not on the database directly.
SSDT database projects in Visual Studio only support SQL Server.
One option is to try Red Gate Source Control for Oracle, a tool developed by the company I work for. This supports both TFS and Subversion. I'd be interested to know if this is something that might work for you.
You can use Toad to integrate Microsoft TFS changes. Please see : http://www.toadworld.com/products/toad-for-oracle/m/media-library/689.aspx

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 :)

Resources