This question is locked. New answers and comments are not allowed.
Hello.
I'm using fluent mapping.
I defined two classes:
My mappings:
Foreign keys will appear in base, but without cascade delete for Parameters.
Tell me please what I'm doing wrong?
I'm using fluent mapping.
I defined two classes:
public class BaseContent{ public BaseContent() { Parameters = new List<BaseParameter>(); } public Guid Id { get; set; } public Guid? ParentId { get; set; } public int Number { get; set; } public string Name { get; set; } public bool IsWork { get; set; } public string NameOfWork { get; set; } public string Basis { get; set; } public string MeasureA { get; set; } public string MeasureB { get; set; } public bool IsChanged { get; set; } public IList<BaseParameter> Parameters { get; set; }}public class BaseParameter{ public Guid Id { get; set; } public Guid WorkId { get; set; } public int Number { get; set; } public string Name { get; set; } public BaseContent Work { get; set; }}My mappings:
var baseContentConfiguration = new MappingConfiguration<BaseContent>();baseContentConfiguration.MapType(x => new { x.Id, x.ParentId, x.Number, x.Name, x.IsWork, x.NameOfWork, x.Basis, x.MeasureA, x.MeasureB }).ToTable("BaseContents");baseContentConfiguration.HasProperty(x => x.Id).IsIdentity(KeyGenerator.Guid);baseContentConfiguration.HasProperty(x => x.Name).HasColumnType("nvarchar(MAX)");baseContentConfiguration.HasProperty(x => x.NameOfWork).HasColumnType("nvarchar(MAX)");baseContentConfiguration.HasProperty(x => x.Basis).HasColumnType("nvarchar(MAX)");baseContentConfiguration.HasProperty(x => x.MeasureA).HasColumnType("nvarchar(MAX)");baseContentConfiguration.HasProperty(x => x.MeasureB).HasColumnType("nvarchar(MAX)");baseContentConfiguration.HasAssociation(x => x.Parameters) .WithOpposite(y => y.Work) .HasConstraint((x, y) => x.Id == y.WorkId).IsManaged().IsDependent().IsRequired();configurations.Add(baseContentConfiguration);var baseParameterConfiguration = new MappingConfiguration<BaseParameter>();baseParameterConfiguration.MapType(x => new { x.Id, x.WorkId, x.Number, x.Name }).ToTable("BaseParameters");baseParameterConfiguration.HasProperty(x => x.Id).IsIdentity(KeyGenerator.Guid);baseParameterConfiguration.HasProperty(x => x.WorkId).IsNotNullable();baseParameterConfiguration.HasProperty(x => x.Name).HasColumnType("nvarchar(MAX)");configurations.Add(baseParameterConfiguration);Foreign keys will appear in base, but without cascade delete for Parameters.
Tell me please what I'm doing wrong?