我正在使用实体框架先学习代码。在问题出现之前,我有:更新模型后更新数据库无法正常工作
public class Book
{
[Key]
public int Id { get; set; }
[Required]
public string Title { get; set; }
[Display(Name = "Publication Name")]
public DateTime PublicationDate { get; set; }
[Required]
public float Edition { get; set; } // We might have a 2.5 edition. Rare but happens
public Author Author { get; set; }
}
我也有几个控制器和视图。我向数据库添加了一条记录,以测试CRUD是否有效,然后将其删除。
然后我加[Required]
到Author Author
并试图运行迁移,并且update-database
。它只是喊我说:
Could not find any resources appropriate for the specified culture or the neutral culture. Make sure "assignment1.Migrations.Addrequiredtoauthorinbookcs.resources" was correctly embedded or linked into assembly "assignment1" at compile time, or that all the satellite assemblies required are loadable and fully signed.
任何想法我做错了什么,以及如何解决它?
更改为'public virtual Author Author {get;组; }'以避免循环引用。 –
什么是虚拟的? – alex3wielki
在实体框架中,Virtual是一个用于激活延迟加载的关键字。 –