c# - 如何不首先保留属性 EF4 代码?

标签 c# .net entity-framework entity-framework-4 ef4-code-only

如何使用 codefirst EF4 创建非持久属性?

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

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

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

最佳答案

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

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

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

关于c# - 如何不首先保留属性 EF4 代码?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3595404/

相关文章:

entity-framework - 配置 npgsql 以与 .NET 3.5 和 EF 一起使用

c# - 在 DataGridView 中,在添加新行时将列的 ReadOnly 属性设置为 false,更新其 true (c#.net)

c# - 对于特定属性,您如何在 ModelState 中获取错误?

.net - WinForms ListView 控件上的多行列表项?

entity-framework - EF7 RC1 无法识别术语 'Scaffold-DbContext'

c# - 改进从 Entity Framework 生成的查询

c# - HttpWebRequest C# 的 API 超时错误 |与 postman 和 restsharp 一起工作

c# - 'struct'限制是什么意思?

c# - NEST中的NOT LIKE查询

.net - Appveyor - .NET MVC 和 NodeJS 构建