EF4中多元化方法的定制 [英] Customization of Pluralize method in EF4

查看:70
本文介绍了EF4中多元化方法的定制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在EF中自定义复数功能?我发现了一些文章如何在其他项目中使用它,但我想提供我自己的复数并配置EF使用它而不是默认的。

Is it possible to customize pluralize function in EF? I found some articles how to use it in other projects but I would like to provide my own pluralization and configure EF to use it instead of the default one.

这就是我想要的实现。如果有更好的方法而不是自定义复数方法,我将不胜感激:

Here comes what I would like to achieve. I would appreciate any tips if there is better way than customizing pluralization method:

我们使用数据库模型第一种方法并具有表和列的命名约定 - 所有小写的下划线分隔符(例如[ customer_invoice] [amount_quantity_id])。当我生成EF模型时,我会得到一个名为'customer_invoice'的类,但是
我想要'CustomerInvoice'和列AmountQuantityId。我可以在概念模型中指定必需的名称,这很好。但是,如果数据库模型没有修复,并且在开发过程中有很多变化,概念性
模型的维护变得越来越困难。

We use database model first approach and have naming conventions for tables and columns - all lowercased with underscore separator (e.g. [customer_invoice].[amount_quantity_id]). When I generate EF model I'll get class named 'customer_invoice', but I would like to have 'CustomerInvoice' and column AmountQuantityId. I can specify required names in conceptual model, which is nice. However, if the database model is not fixed and there are lots of changes during development, the maintenance of conceptual model is getting difficult.

此外,我们添加了一些审计列到大多数表(如创建/修改日期等),它们通过绑定到默认值(例如getdate()函数)填充或使用触发器填充。这些列纯粹用于审计
数据库,它们不应该在业务逻辑中可用 - 我会将它们从概念模型中排除。同样,问题在于稍后从数据库更新EF模型,因为我无法自动指定预定义的一组列的通用过滤。
我需要调用一些过滤和重命名功能来决定EF模型(.edmx文件)的内容。手动更改概念模型的优势在于可以重复修改,因此我可以简单地清除模型并从头开始重新生成
,然后再次应用更改。

Further, we have added some auditing columns to majority of tables (like creation/modification date, etc), which are filled by binding to default values (e.g. to getdate() function) or are filled in using trigger. This columns are purely for auditing database and they should not be available in business logic - I would exclude them from conceptual model. Again, the problem is with later updating of the EF model from database as I can't specify generic filtering of predefined set of columns automatically. I'd need to have some filtering and renaming function to be called to decide what comes into EF model (.edmx file). The advantage over manual changing of conceptual model is that the modification could be repeated so I can simply clear the model and have it to re-generate from scratch and then apply the changes again.

谢谢

eXavier

推荐答案

我正在调查您的问题并会尽快回复。

I am looking into your questions and will respond as soon as possible.

谢谢,

Cathy Miller

Cathy Miller

Microsoft在线社区支持

Microsoft Online Community Support


这篇关于EF4中多元化方法的定制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆