在MVC中的Entity框架中动态添加表 [英] Add table dynamically in Entity framework in MVC

查看:147
本文介绍了在MVC中的Entity框架中动态添加表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个MVC应用程序,其中我需要动态添加表,表名称是动态准备的。有没有办法检查表的存在,如果不存在,那么将其添加到实体模型中。



如果我们能够创建表,那么如何我们可以使用实体模型的对象访问动态创建的表名称?

解决方案

否。如果要在EF中使用新表,还需要在上下文中显示相关实体(类),映射和 ObjectSet 在这里你有一些想法这是否意味着在EF中使用动态方法。


I have an MVC application in which i need to add the table dynamically i.e table name is prepared dynamically. Is there any way we can check for the existence of a table and if not exist then add it in entity model.

If we can are able to create the table then how we can access the dynamically created table name using the object of entity model?

解决方案

No. If you want to use new table in EF you also need related entity (class), mapping and ObjectSet exposed in your context. Here you have some ideas what does it mean to use "dynamic" approach in EF.

这篇关于在MVC中的Entity框架中动态添加表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆