Search code examples
c#wpfentity-frameworksql-server-data-tools

What type of c# project should an SSDT model be placed in?


Sorry if this is a totally noob question but I just can't seem to find a starting point on this.

From what I've gathered so far SSDT was developed with the idea that it would be used in a different project that that of the main app for database related coding. I figured that instead of complaining about how much I like the old version back, I'd try things their way and see how well it goes but I can't seem to get a handle on where to begin over here.

Basically I want to use a code first approach and create a database from a designer. If I'm going to create a new project to handle the entity framework, what type of project should it be? a C# class library, WPF.. something else?

I'm not sure if it's of any relavance but the app I'm working on is a WPF app and the database is MySQL.


Solution

  • If you want to use a code-first approach, then that means that the database will be generated by the code. Thus, you will not have a separate database-project, since that would mean that your database is kept in two places. Therefore, your options are:

    1. Use code-first. This usually means a class library (although asp.net mvc usually has the context with entities in the asp.net mvc project, let's call that an exception to the rule). The class library will contain classes with which your database will be generated.
    2. Use a database project, an SSDT project. Your database will be defined here, and when you deploy this project the database will be generated/updated.

    Note: AFAIK an SSDT project is specific to SQL Server, so since you are using a MySql database it is not an option.