Answer the question
In order to leave comments, you need to log in
How to add fields to a database table that participate in relationships using FluentAPI?
Hello.
There was a problem when working with MySQL + EF6.
There are 2 models:
public class Foo{
public Guid Id { get;set; }
public string Name { get; set; }
public List<Boo> Boos { get; set; }
}
public class Boo{
public Guid Id { get;set; }
public string Name { get; set; }
public Foo Foo { get; set; }
}
public class FooConfiguration : EntityTypeConfiguration<Lot>
{
public FooConfiguration()
{
ToTable("foo_table");
Property(x => x.Id).HasColumnName("foo_id");
Property(x => x.Name).HasColumnName("foo_name");
HasMany(x => x.Boo).WithRequired(x => x.foo);
}
}
public class BooConfiguration : EntityTypeConfiguration<Lot>
{
public BooConfiguration()
{
ToTable("boo_table");
Property(x => x.Id).HasColumnName("boo_id");
Property(x => x.Name).HasColumnName("boo_name");
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question