先映射私有属性实体框架代码 [英] mapping private property entity framework code first

查看:35
本文介绍了先映射私有属性实体框架代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 EF 4.1,并且正在寻找一个很好的解决方法来解决缺乏枚举支持的问题.int 的支持属性似乎合乎逻辑.

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:

如何首先使用 EF 4.1 代码映射私有财产?

How can I map a private property using EF 4.1 code first?

推荐答案

您不能先在 EF 代码中映射私有属性.您可以尝试将其更改为 protected 并在继承自 EntityConfiguration 的类中配置它.
编辑
现在改了,看这个https://stackoverflow.com/a/13810766/861716

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屋!

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