使用 EF4 创建模型时,我想替换所有下划线以及表/列前缀,以便模型读取干净。我们的数据库的结构类似于:
Table:ABC_Customer
-Column:ABC_Customer_Id
-Column:Name
-Column:ABC_Customer_Type_Id
Table:ABC_Customer_Type
-Column:ABC_Customer_Type_Id
-Column:Name
我想有这样的实体名称:
Entity:Customer
-Property:CustomerId
-Property:Name
-Property:CustomerTypeId
-NavigationProperty:CustomerType
等等等等。
生成 edmx 文件时,EF 设计器会完全按照它们在数据库中的显示方式命名所有实体。我知道可以使用 T4 模板修改此行为,但我刚刚发现我可以在设计器中重命名实体,这会在 edmx 文件中生成 EntitySetMapping 元素,因此 T4 似乎有点过头了。似乎我只想对 edmx 文件进行后处理,而不使用 T4 模板,因为在替换之后,我想要默认行为。哪种方法最合适,为什么?