-
Notifications
You must be signed in to change notification settings - Fork 857
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
不是bug,关于CodeFirst的疑问 #1887
Comments
对于code first来讲,他们都是独立的单体,需要分别同步结构 |
应该如何操作呢? 尝试一(无效): freeSql.CodeFirst.Entity<Schedules>(p =>
{
p.HasKey(a => a.Id);
p.Property(a => a.Name);
p.Property(a => a.Description);
p.Property(a => a.IsActive);
p.Property(a => a.CreateTime);
p.HasMany(a => a.ScheduleTasks).HasForeignKey(a => a.Pid);
p.ToTable(nameof(Schedules));
}).SyncStructure(); 尝试二(无效): public class SchedulesConfiguration : IEntityTypeConfiguration<Schedules>
{
public void Configure(EfCoreTableFluent<Schedules> p)
{
p.HasKey(a => a.Id);
p.Property(a => a.Name);
p.Property(a => a.Description);
p.Property(a => a.IsActive);
p.Property(a => a.CreateTime);
p.HasMany(a => a.ScheduleTasks).HasForeignKey(a => a.Pid);
p.ToTable(nameof(Schedules));
}
}
fsql.CodeFirst.ApplyConfiguration(new SchedulesConfiguration()); |
freeSql.CodeFirst.SyncStructure<ScheduleTasks>();
freeSql.CodeFirst.SyncStructure<Schedules>(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
问题描述及重现代码:
目的自定义外键字段
Pid
而非默认的SchedulesId
执行后数据库只生成
ScheduleTasks
这个表,Schedules
却没有生成。怎么回事呢?数据库版本
MySql 8.0
安装的Nuget包
FreeSql v3.2.83
FreeSql.DbContext v3.2.83
.net framework/. net core? 及具体版本
net8
The text was updated successfully, but these errors were encountered: