使用EF从我们applictaion动态数据库中创建表 [英] create table in database using EF from our applictaion Dynamically

查看:418
本文介绍了使用EF从我们applictaion动态数据库中创建表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

才能在数据库中创建表从我们的Web应用程序使用动态EF,其中用户定义字段的表。
我工作的MVC 4。

Can we create table in database from our Web application dynamically using EF where user define fields for table. I am working on MVC 4.

这可能吗?
如果是的话该怎么办呢。

Is it possible ? and if yes then how to do it.

推荐答案

取决于你动态这里了解。更改上下文的运行时版本心不是可能的。

Depends on what you understand by dynamic here. Changing the runtime version of the Context isnt possible.

生成,编译,加载新的code是。因此,一个新的环境,和POCO code可以声明。编译和加载。全部由一块运行code的控制。

Generating, compiling, loading NEW code is. So a new context, and POCO code can be declared. Compiled and loaded. All controlled by a piece of running code.

不过,正在进行的生命周期变得复杂。
使用code首先迁移变得棘手。结果
如何管理chnages到正式版的扩展。
如何合并正在进行的开发和督促。
在管理中产生的code流利API映射是可怕的。
你不能做这一切的属性。

However, the ongoing lifecycle gets complicated. The use of code first migrations becomes tricky.
How to manage chnages to extensions in Prod. How to merge ongoing dev and prod. Managing the mapping in Fluent API in generated code is awful. You cant do it all in Attributes.

上下文后空翻和自动迁移噩梦已经花了我很多的夜晚。

The context backflips and automated migrations nightmares have cost me many a night.

与主构建自然延伸和生产处理/地区实施扩展变得非常难。你需要确保它们合并到构建。

Dealing with main build natural extensions and production/localised implementation extension gets VERY hard. You need to make sure they are incorporated back into the build.

和必是你需要知道如何在同一时间管理同一数据库不同的上下文。

And a must is You need to know how to manage different contexts on the same DB at the same time.

我目前所面对的正是这个烂尾工程。我已经把它搁置,直到我们在EF6。
我希望自己独自度过数周在这个话题。
和IM仍然不知道我要继续沿着这条道路。
我很认真地考虑迁移到元数据/桶数据的方法。

I have exactly this UNFINISHED project at the moment. I have put it on hold until we are on EF6. I expect to spend several weeks on this topic alone. And Im still not sure i want to continue down this path. I am seriously considering moving to a meta Data / bucket data approach.

所以它是可能的,但困难的(我认为至少)。它会由于多个上下文支持在EF6容易。但它仍然会从这些问题多数受害,需要code生成和编译仍。

So It is possible but difficult (In my opinion at least). It will be easier in EF6 due to the multiple context support. But it will still suffer from most of these issues and require code generation and compilation still.

好运...

这篇关于使用EF从我们applictaion动态数据库中创建表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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