Hi, Liming,
There is no exception. The only worng this is that the generated migration doesn't contain the foreing key creation code.
I have the following AbpUser class:
public class AppUser : FullAuditedAggregateRoot<Guid>, IUser
{
...
public Guid? SettingId { get; set; }
public virtual ICollection<UserClient> Clients { get; set; }
private AppUser()
{
Clients = new List<UserClient>();
}
}
UserClient is defined like this:
public class UserClient : Entity<Guid>
{
public string Name { get; set; }
public Guid UserId { get; set; }
}
When I add the relation one to one for Settings and many to one between AbpUser and UserClients, there is no relation in the migration class at all.
builder.Entity<AppUser>(b =>
{
b.ToTable(AbpIdentityDbProperties.DbTablePrefix + "Users"); //Sharing the same table "AbpUsers" with the IdentityUser
b.ConfigureByConvention();
b.ConfigureAbpUser();
b.ConfigureExtraProperties();
...
b.HasOne<Setting>().WithOne().HasForeignKey<AppUser>(x => x.SettingId);
b.HasMany(x => x.Clients).WithOne().HasForeignKey(x => x.UserId);
});
Reading the article didn't resolve the migration issue for me. How do I add 2 relations (one AbpUser should have many UserClients) and (one ApbUser has one Setting) to get correct relations in the migration?