With Entity Framework we had HasRequired
on a field. What is the alternative replacement for that with EF core?
https://msdn.microsoft.com/en-us/library/jj591620(v=vs.113).aspx
I tried with HasRequired
but it throws error.
Check out the Required and Optional Relationships in the EF Core Documentation.
Specifically I think you'll want something like:
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<MyEntity>()
.HasOne(p => p.Relationship)
.IsRequired();
}
Or something like that - you haven't given much information to go on
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.