如何永久性属性EF4代码首先? [英] How not persist property EF4 code first?

查看:141
本文介绍了如何永久性属性EF4代码首先?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用codefirst EF4进行非持久化属性?

How do I make non persisted properties using codefirst EF4?

MS说有一个StoreIgnore属性,但我找不到。

MS says there is a StoreIgnore Attribute, but I cannot find it.

http://blogs.msdn.com/b/efdesign/archive/2010/03/30/data-annotations-in-the-theity- framework-and-code-first.aspx

有没有办法使用EntityConfiguration进行设置?

Is there a way to set this up using EntityConfiguration?

推荐答案

在EF Code-First CTP5中,您可以使用 [NotMapped] 注释。

In EF Code-First CTP5, you can use the [NotMapped] annotation.

using System.ComponentModel.DataAnnotations;
public class Song
{
    public int Id { get; set; }
    public string Title { get; set; }

    [NotMapped]
    public int Track { get; set; }

这篇关于如何永久性属性EF4代码首先?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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