开发者

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

开发者 https://www.devze.com 2023-02-28 18:02 出处:网络
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?

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 thos开发者_开发技巧e 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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消