首先映射私有财产实体框架代码 [英] mapping private property entity framework code first
本文介绍了首先映射私有财产实体框架代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
[必需]
public VenueType类型
{
get {return(VenueType)TypeId ; }
set {TypeId =(int)value; }
}
private int TypeId {get;组; }
但是,如何将此属性设置为私有并仍然映射。换句话说:
首先如何使用EF 4.1代码映射私有财产?
解决方案
您无法首先映射EF代码中的私有属性。您可以尝试将其更改为 protected
,并在继承自 EntityConfiguration
的类中进行配置。 br>
修改
现在更改,请参阅此 https: //stackoverflow.com/a/13810766/861716
I am using EF 4.1 and was look for a nice workaround for the lack of enum support. A backing property of int seems logical.
[Required]
public VenueType Type
{
get { return (VenueType) TypeId; }
set { TypeId = (int) value; }
}
private int TypeId { get; set; }
But how can I make this property private and still map it. In other words:
How can I map a private property using EF 4.1 code first?
解决方案
you can't map private properties in EF code first. You can try it changing it in to protected
and configuring it in a class inherited from EntityConfiguration
.
Edit
Now it is changed , See this https://stackoverflow.com/a/13810766/861716
这篇关于首先映射私有财产实体框架代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文