问题
I'm using EF4 in model (DB First), POCO in entities, ASP.Net in UI. I have a Biz layer of course. I need to design dynamic form generator. I decide to create a table from forms design by users, and then update my EF model in runtime, generate POCO objects and biz logic in runtime, and then compile them in runtime.
I have problem about updating model in runtime. any help?
Thanks in advance -Hamid
回答1:
EF is not tool for your problem! EF is build around simple concept - mapping and classes are defined at design time. If you want to do anything else EF is not for you because you are going to not supposed way of using EF = no support / unexpected behavior / unexpected challenges and big increase in complexity and costs.
You need either to use direct SQL to work with your dynamically created tables or you need to spend much more time in your design phase and build meta model which will consist of set of static tables defined in design time which will be able to hold any kind of your form.
来源:https://stackoverflow.com/questions/10308853/changing-ef-model-and-creating-new-entities-in-runtime