0

I've been using EF for a while (4 with model first) and so far I've not created any mapping manually. Whenever I need more entities/tables, I add an entity and the associations (all foreign key) and click "update database from model", which, as is well known, doesn't update any database from the model (although it does need a database connection for reasons I don't know). What it does is generating a storage model and the appropriate mappings to it, which are all stored back to the same edmx xml file.

So far, that has always been enough for me but I'm wondering what the workflow would be if one is to tweak the mappings and storage model manually. "Update database from model" overwrites all manual customization - so how is one to fix most of the mappings and storage model? Because I clearly don't want to do it all by hand - in fact I couldn't even figure out how to actually create a table in the storage model other than by editing the edmx in the xml.

4

1 回答 1

1

我也有同样的问题。我只是使用多种方法。如果我向数据库添加一个字段,我只需将该字段添加到模型文件中。如果我进行重大重组,我会删除该表并通过从数据库生成它来重新创建它。有时,我实际上将 edmx 编辑为 XML 以更改或添加内容。您只需要弄清楚哪种流程最适合您。通过使用 T4 模板或更改数据库并重新生成,我设法避免了 edmx 中的大量定制。

于 2012-11-14T15:02:27.863 回答