在运行时更新实体框架

在运行时更新实体框架

问题描述:

我有一个关于EF(实体框架)的问题



如果我有一个允许用户添加列和/或表的数据库(没有删除) )以及运行时的模式,EF可以处理这些对底层数据存储的修改而不需要太多调整,或者这个问题太多了?可以在运行时在代码中重新生成EF及其类吗?



我想更改数据库名称,模式名称表示运行时的连接字符串,EF将动态在运行时更新以前的EF模型以及它的实体,我想使用该实体假设(例如,类实体)在运行时将数据(如json / atom + xml)返回到webapi odata服务。如果可能的话,请任何人都可以通过尽早使用WebAPI OData提供源代码或演示项目来向我发送解决方案。在此先感谢。



我尝试过:



.. .................................................. ........................

I have a question about EF(Entity Framework)

If I have a database that allows the users to add columns and/or tables with columns ( no deletions ) as well as schemas at run time can the EF handle these modifications to the underlying data store without much tweaking or is this asking too much? Can it regenerate the EF and its classes in code at run time?

I want to change the database name, schema name means connection string at runtime and the EF will dynamically update the previous EF Model as well as it's entity at runtime and I want to use that entity suppose(e.g Category Entity) to return data like json/atom+xml to as webapi odata service at runtime. If possible then please anyone can send me solution by giving source code or demo project using WebAPI OData as early as possible. Thanks in advance.

What I have tried:

............................................................................

你问太多EF了。如果这是一项要求(即时更改数据库架构),则永远不应使用EF。
You're asking WAY too much of EF. If this was a requirement (change the DB schema on-the-fly) EF should never have been used.