实体框架中的条件注释? [英] Conditional Annotation in Entity Framework?

查看:61
本文介绍了实体框架中的条件注释?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想以某种方式有条件地应用 

I'd like to somehow conditionally apply 

[DatabaseGenerated(DatabaseGeneratedOption) .Identity)]

[DatabaseGenerated(DatabaseGeneratedOption.Identity)]

[DatabaseGenerated(DatabaseGeneratedOption.None)]

[DatabaseGenerated(DatabaseGeneratedOption.None)]

我可以采用什么方法采取这样做,所以我可以继续使用一个通用基类。

What approach can I take to do that so I can continue to use one generic base class.

推荐答案

有条件吗?  什么?  属性在编译时应用。

Conditionally?  On what?  Attributes are applied at compile time.

你能不把属性放在派生类上吗?

Can you not put the attribute on the derived class?


这篇关于实体框架中的条件注释?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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