问题描述
我想使用实体框架。但是,我还要求允许我的用户在系统中定义自定义字段。我想仍然使用实体框架,而不是使用具有哈希表属性的部分类。
I want to use the entity framework. However I also have the requirement of allowing my users to define custom fields in our system. I would like to still use the entity framework and not use a a partial class with a hash table property.
以下是我正在考虑的解决方案,但它不是简单的所以我想看看是否有更好的方法。
Below is the solution I was thinking of, however it is not simple so I would like to see if there is a better way.
我的想法是,有一个ModelManager对象,将在适当的表上创建一个列,修改EDM文件,并使用edmgen.exe编译文件。这一切都必须发生在与应用程序不同的进程和/或应用程序域中,因为应用程序将引用所生成的程序集。当应用程序重新启动时,它将可以访问新添加的字段。
My idea currently, is to have a ModelManager object that would create a column on the appropriate table, modify the EDM files, and compile the files using the edmgen.exe. This would all have to happen in a different process and/or appdomain than the application, since the application would reference the resulting assembly. When the application restarts it will have access to the newly added field.
这是实现框架的唯一方法吗?感谢您的时间。
Is this the only way to do this with the Entity Framework? Thanks for your time.
推荐答案
在实体框架团队和Julie Lerman阅读了一些博客文章后,听起来他们正在寻找在下一个版本中更容易。这就意味着据我所知,我在问题中所说的方式是动态地向实体框架添加字段的最佳方法。
After reading some blog entries by the Entity Framework team and Julie Lerman, it sounds like they are looking at making this easier for the next version. Which means as far as I can tell, the way I stated in the question is the best way to dynamically add fields to the entity framework.
这篇关于实体框架:在运行时添加属性/实体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!