I have below code
using System;
using IranKala.Domain.Entities;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace IranKala.Persistence.Configurations
{
public class PriceConfiguration : IEntityTypeConfiguration<Price>
{
public void Configure(EntityTypeBuilder<Price> builder)
{
builder.HasKey(e => e.PriceId);
builder.Property(e => e.PriceId).ValueGeneratedOnAdd();
builder.HasRequired
}
}
}
and I receive below error when try to use this enter link description here
entitytypebuilder<> does not contain a definition for hasrequired
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