简体   繁体   English

首先向实体框架数据库中的数据库添加表

[英]Adding tables to database in Entity Framework Database first

I have a project that is almost completed using Database first approach. 我有一个使用数据库优先方法几乎完成的项目。 I have a module in the application that manages plugins that could be plugged into the application at runtime without recompiling the application. 我在应用程序中有一个模块,该模块管理可以在运行时插入到应用程序中的插件,而无需重新编译应用程序。 The challenge is if the plugin will need to create tables in database, how do I do that ? 挑战在于,如果插件需要在数据库中创建表,该怎么办? The only way I know now is to delete '.edmx' and regenerate it from the database. 我现在知道的唯一方法是删除“ .edmx”并从数据库中重新生成它。 But that's not what I want to do as I want individuals to plugin their small apps without having to drop and recreate '.edmx'. 但这不是我想要做的,因为我希望个人无需删除并重新创建“ .edmx”即可插入其小型应用程序。

Your plug-in should use it's own datacontext with it's own edmx file. 您的插件应将其自己的datacontext与它自己的edmx文件一起使用。 The main app will not ever know about the additional tables. 主应用程序永远不会知道其他表。 If the plug-in gets instantiated it should create the additional tables that it uses. 如果插件实例化,则应创建其使用的其他表。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM