简体   繁体   English

动态地在运行时/添加属性中的EF1 /更改模型中的动态实体

[英]Dynamic entity in EF1/change model in runtime/add property dynamicaly

I want to give users the possibility to dynamically add new columns at the runtime. 我想为用户提供在运行时动态添加新列的可能性。 I am using the Entity framework v1 ... 我正在使用Entity Framework v1 ...

I did manage to read as xml and then change ssdl , csdl and msl files and construct new workspace and new object context... But the problem is when i dynamically add new columns in EF model the underlying object is not changed, of course. 我确实设法读取为xml,然后更改了ssdl,csdl和msl文件,并构造了新的工作区和新的对象上下文...但是问题是,当我在EF模型中动态添加新列时,基础对象当然不会更改。

How to get the data from model without having concrete entity ? 如何在没有具体实体的情况下从模型获取数据? Anonymous type or DBDataRecord would be just fine... Or even some new type created at runtime... 匿名类型或DBDataRecord会很好...甚至在运行时创建一些新类型...

Any idea ? 任何的想法 ?

Changing the Entity Model CSDL/SSDL will not change the types, because they are used to generate the types at design time. 更改实体模型CSDL / SSDL不会更改类型,因为它们用于在设计时生成类型。 I don't think there is any practical way to modify those types at runtime to reflect your changes to the model. 我认为没有任何实用的方法可以在运行时修改这些类型以反映对模型的更改。

In v1, you would need to generate a new assembly. 在v1中,您将需要生成一个新的程序集。 This would also require redistributing EdmGen. 这也将需要重新分发EdmGen。 I don't know if that's legal. 我不知道那是否合法。

In EF v4, you could probably combine C# dynamic types with code-only modeling and come up with a pretty slick solution to your problem. 在EF v4中,您可以将C#动态类型与仅代码建模结合起来,并为您的问题提供一个漂亮的解决方案。

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

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