如何在使用entity framework代码时忽略一个属性首先
entity framework代码首先将根据模型在数据库中自动创build一个表。
有没有一个属性可以避免这种情况?
将[System.ComponentModel.DataAnnotations.Schema.NotMapped]属性添加到属性。 
 根据接受的答案和类似的问题/答案 ,除了[NotMapped]您还可以使用Fluent API指定它: 
 protected override void OnModelCreating(DbModelBuilder modelBuilder) { modelBuilder.Entity<TheModelAffected>().Ignore(t => t.TheIgnoredProperty); base.OnModelCreating(modelBuilder); } 
 如果你喜欢简洁的话, [NotMapped]是简短的版本。 当然,你会添加: 
 using System.ComponentModel.DataAnnotations.Schema; 
到你们class上