更改代码优先 EF4 中的列名称约定
我将 EF4 与 CodeFirst 结合使用。
public class MyContext : DbContext
{
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
modelBuilder.Conventions.Remove<XXX>();
modelBuilder.Conventions.Add<XXX>());
}
}
我应该添加或删除什么约定才能使所有数据库标识符(如列名、表名、存储过程等)均为大写(或不带引号)?
Oracle DB 中区分大小写(带引号)的标识符极大地降低了用户友好性。
I'm using EF4 with CodeFirst.
public class MyContext : DbContext
{
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
modelBuilder.Conventions.Remove<XXX>();
modelBuilder.Conventions.Add<XXX>());
}
}
What convention should I add or remove to make all DB identifiers (like column names, table names, stored procedures etc) to be in uppercase (or unquoted)?
Case-sentitive (quoted) identifiers in Oracle DB greatly suck in user-friendliness.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我不知道如何使用约定来做到这一点,但看看 StoreNameAttribute。您可以应用于上下文、实体和属性。
实体代码优先中的数据注释
I don't know how can you do this with conventions but take a look at StoreNameAttribute. You can apply on context, entities and properties.
Data Annotations in Entity Code First
考虑产品和客户类
编辑:
我尝试做这样的事情,但似乎不起作用,我不知道为什么
我最好的方法很
抱歉,我现在无能为力,但我会继续努力的
Consider the Product and Customer class
EDIT:
I tried to do something like this, but it seems that doesn't work, idk why
my best approach was
sorry, I can't help right now, but I'll keep trying.