在运行时实体Framework Core C#中动态添加表格到数据库

发布于 2025-01-24 01:50:55 字数 282 浏览 4 评论 0原文

我正在寻找一种使用EntityFramework Core在运行时将表添加到数据库的方法,我想使用modelBuilderMigrationBuilder,但我无法通过操作到达这些类控制器中的方法我不想使用onModeLcreating,因为它只有在执行应用程序后才运行一次,是否有任何解决方案可以动态地将表添加到数据库,而无需执行以下步骤手册”停止应用程序的运行,并在模态中手动添加一个类,然后进行“添加迁移”,然后“ update-database'”?

I'm looking for a way to add table to database in runtime with entityframework core, i would like to use ModelBuilder or MigrationBuilder but I can't reach these class via Action method in controller i don't want to use OnModelCreating because it will run only one time once the application is executed, is there any solution to add table to database dynamically without need to do the following steps manual "stop the running of the application and add manually a class to modals and do 'add-migration' then the 'update-database'" ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文