Deploying my application that uses the Entity Framework and creating databases on a client machine

I created a model in the Entity Framework, and then created a database with this model.

What would be the best way to do this on the client machine?

If the Entity Framework tries to connect to the database and find the necessary tables, and they do not exist, this will result in an error.

What is the best way to create these tables on a client machine?

Using the SQL file generated by the model? If so, how can I do it?

In case it matters, I use SQL Server Express, although this question may be kind of common to any database.

+4
source share
1 answer

You can copy this script and use it in the client ... I do not understand how to do this.

This article contains information on how to generate an SQL script to create a database.

http://www.dotnetcurry.com/ShowArticle.aspx?ID=606

They say that to right-click the constructor object, and then "Create a database from the model ...", after which you enter the database connection information, click "Next" and you have SQL.

EDIT:

Information on how to read and execute the SQL file:

I found this on a forum in Microsoft:

http://social.msdn.microsoft.com/Forums/en-US/adodotnetdataproviders/thread/43e8bc3a-1132-453b-b950-09427e970f31/

This question is here in SO:

How to execute .SQL script file using C #

There is no native .Net way to do this in agmatic DB mode, I think.

+1
source

All Articles