How do Visual Studio 2013 Database Projects work with TFS online and EntityFramework code first migrations

entity-framework git sql-server tfs visual-studio

Question

Fairly long title, but hopefully self-explanatory!

I'm starting a new project in Visual Studio 2013 using Entity Framework 5.0 with code first migrations.

I've connected my project to TFS Online using git - I'm interested in trying TFS Online as it offers source control management for 5 free projects (similar to BitBucket) but with strong Visual Studio integration.

I've not used Database projects in Visual Studio 2013 and I've found little information for how this all fits together.

What I'm trying to acheive is to create a simple Visual Studio solution with 2 projects - one an MVC .NET project and the other a database project. My goal is that code first migrations will make the neccessary changes to the sql scripts in the database project (which are managed under git source control). My web.config points to a local .mdb file as my database which is what is updated when I run update-database in EF which is what I feel is the problem.

How can I point EF to use my database project for code migration, and subsequently how can I automatically build my development database into a local .mdb file when debugging my solution?

1
15
10/5/2013 10:58:22 AM

Accepted Answer

Entity Framework Code First is a way to manage your SQL Schema. The single source of the truth lives in your code base. Migrations adds a way to move from one version of the schema to another. The SQL schema is a by-product of the build process.

SQL Server Database projects are also a way to manage your SQL Schema. The single source of the truth lives in your SQL Server Database project. You can use schema compare to generate scripts that move from one version to another.


Given that these technologies overlap in their intent and functionality, it doesn't really make sense to use them together. When you're using entity Framework Code First, leverage Migrations when you can (and when the features are sufficient for your situation).

When you're unable to use Migrations, you could use SQL Server Database projects to manage the schema and keep them in source control.

Note:

You should consider installing the SQL Server Data Tools as a replacement for the SQL Server Database projects should you want to use these. The data tools are a more advanced version of these projects, even if they might require Visual Studio 2012 to run for now. I suspect a version for Visual Studio 2013 will be available when Visual Studio 2013 hits RTM

16
10/7/2013 11:21:04 AM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow