Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I created the model in Entity Framework, and then created the database from that model.

What would be the best way of doing this in the client machine?

If Entity Framework try to connect to the database and find the necessary tables and those do not exist, it will give an error.

What is the best way of create those tables in the client machine?

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

In case that matters, I'm using SQL Server Express, although this question could be kind of generic for any database.

like image 217
Oscar Mederos Avatar asked Nov 15 '22 00:11

Oscar Mederos


1 Answers

You can copy that script and use it in the client as well... I don't understand the problem of doing that.

This article has information on how to generate SQL script to generate DB.

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

It say to right-click the entity-designer, and then "Generate Database from Model...", after that you enter the information of the DB connection, click next and you have the SQL.

EDIT:

Information on how to read and execute an SQL file:

I found this one in microsoft forum:

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

This question here in SO:

How to execute an .SQL script file using c#

There is no native .Net way of doing that in a DB agnostic way I think.

like image 122
Miguel Angelo Avatar answered Feb 02 '23 03:02

Miguel Angelo