实体框架 .edmx.sql 文件如何在已部署的应用程序中生成数据库?
我正在 Visual Studio 2010 中构建使用数据库的 ac# 应用程序。 为了创建数据库,我使用了实体框架模型到数据库的方法。
所以在VS中我添加了一个“ADO.NET实体数据模型”文件,然后我设计了模型,然后单击“从模型生成数据库”按钮。 完成此操作后,VS 生成了一个新的 edmx.sql 文件,然后右键单击该文件并选择“Execure SQL”,它在 SQL Server 中创建了包含所有表的数据库。
我必须在 VS 中手动执行所有这些操作才能在 SQL Server 中创建数据库。 但是部署应用程序后如何创建数据库? 我的意思是,如果我为我的应用程序创建一个安装程序,然后将其安装在另一台计算机上,如何让我的应用程序在该计算机上创建数据库?
I'm building a c# application in Visual Studio 2010, that uses database.
To create the database I used Entity Framework model-to-databse approach.
So in VS i added a "ADO.NET Entity Data Model" file, then i designed the model, then clicked the "generate database from model" button.
After I did that VS generate a new edmx.sql file, then right clicked on this file and chose "Execure SQL", and it created the database in SQL Server with all the tables.
I had to do all of this actions manually in VS to create the database in SQL Server.
BUT how does the database get created after I deploy the app?
I mean if i create an installer to my app, then I install it on a different computer, how can I make my app create the database in that computer?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您必须像在开发计算机上那样手动创建数据库(通过运行脚本),或者必须在安装程序中付出更大的努力并添加 自定义操作从包含的脚本创建数据库。
You must either create the database manually as you did on your development machine (by running the script) or you must put much bigger effort to your installer and add custom action to create database from included script.