C# 实体框架核心不';无法创建迁移文件

C# 实体框架核心不';无法创建迁移文件,c#,asp.net,asp.net-core,.net-core,entity-framework-core,C#,Asp.net,Asp.net Core,.net Core,Entity Framework Core,我已经完成了我的模型结构并运行了 sudo dotnet ef迁移添加3-MyMigration 命令,但迁移文件夹中没有创建文件 以下是输出: Project SocioFal (.NETCoreApp,Version=v1.0) will be compiled because project is not safe for incremental compilation. Use --build-profile flag for more information. Compiling

我已经完成了我的模型结构并运行了

sudo dotnet ef迁移添加3-MyMigration

命令,但迁移文件夹中没有创建文件

以下是输出:

 Project SocioFal (.NETCoreApp,Version=v1.0) will be compiled because project is not safe for incremental compilation. Use --build-profile flag for more information.
 Compiling SocioFal for .NETCoreApp,Version=v1.0
 Bundling with configuration from /home/aymeric/dotnet_projects/sociofal/SocioFal/bundleconfig.json
 Processing wwwroot/css/site.min.css
 Processing wwwroot/js/site.min.js
 Compilation succeeded.
    0 Warning(s)
    0 Error(s)
 Time elapsed 00:00:04.0311963
 (The compilation time can be improved. Run "dotnet build --build-profile" for more information)
并使用详细标记:

Project SocioFal (.NETCoreApp,Version=v1.0) will be compiled because project is not safe for incremental compilation. Use --build-profile flag for more information.
Compiling SocioFal for .NETCoreApp,Version=v1.0
Bundling with configuration from /home/aymeric/dotnet_projects/sociofal/SocioFal/bundleconfig.json
Processing wwwroot/css/site.min.css
Processing wwwroot/js/site.min.js
Compilation succeeded.
0 Warning(s)
0 Error(s)
Time elapsed 00:00:13.1481501
(The compilation time can be improved. Run "dotnet build --build-profile" for more information)
Setting app base path /home/aymeric/dotnet_projects/sociofal/SocioFal/bin/Debug/netcoreapp1.0
Finding DbContext classes...
Using context 'ApplicationDbContext'.
因此没有显示错误

以下是使用的上下文:

    public class ApplicationDbContext : IdentityDbContext<ApplicationUser>
{
    public DbSet<GenealogyRelation> GenealogyRelation { get; set; }

    public DbSet<FalEvent> FalEvent { get; set; }
    public DbSet<GenealogyFalEvent> GenealogyFalEvent { get; set; }
    public DbSet<BaptemeFalEvent> BaptemeFalEvent { get; set; }

    public DbSet<AdoptionFalEvent> AdoptionFalEvent { get; set; }

    public DbSet<ConfirmationFalEvent> ConfirmationFalEvent { get; set; }


    public DbSet<GenealogyCityAndFieldFalEvent> GenealogyCityAndFieldFalEvent { get; set; }


    public DbSet<City> City { get; set; }
    public DbSet<FalProfile> FalProfile { get; set; }
    public DbSet<SocialProfile> SocialProfile { get; set; }

    public DbSet<StudyField> StudyField { get; set; }
    public DbSet<UserStudyField> UserStudyField { get; set; }

    public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options)
        : base(options)
    {
    }

    protected override void OnModelCreating(ModelBuilder builder)
    {
        builder.Entity<GenealogyFalEvent>().ToTable("GenealogyFalEvent");
        builder.Entity<BaptemeFalEvent>().ToTable("BaptemeFalEvent");
        builder.Entity<ConfirmationFalEvent>().ToTable("ConfirmationFalEvent");
        builder.Entity<AdoptionFalEvent>().ToTable("AdoptionFalEvent");
        base.OnModelCreating(builder);
        // Customize the ASP.NET Identity model and override the defaults if needed.
        // For example, you can rename the ASP.NET Identity table names and more.
        // Add your customizations after calling base.OnModelCreating(builder);
        builder.Entity<GenealogyRelation>().HasKey((e) => new {e.ChildID, e.GenealogyFalEventID, e.ParentID});
        builder.Entity<UserCity>().HasKey(u => new {u.CityID, u.UserID});
        builder.Entity<UserStudyField>().HasKey(u => new {u.StudyFieldID, u.UserID});

    }
}
public类ApplicationDbContext:IdentityDbContext
{
公共DbSet系谱关系{get;set;}
公共数据库集事件{get;set;}
公共DbSet generalogyFalEvent{get;set;}
公共DbSet BaptemeFalEvent{get;set;}
公共数据库集采用FalEvent{get;set;}
公共数据库集确认FalEvent{get;set;}
public DbSet generalogycity和dfieldfalevent{get;set;}
公共数据库集城市{get;set;}
公共数据库集配置文件{get;set;}
公共数据库集社交程序文件{get;set;}
公共数据库集研究字段{get;set;}
公共DbSet UserStudyField{get;set;}
公共应用程序DBContext(DbContextOptions选项)
:基本(选项)
{
}
模型创建时受保护的覆盖无效(ModelBuilder)
{
builder.Entity().ToTable(“系谱法事件”);
builder.Entity().ToTable(“BaptemeFalEvent”);
builder.Entity().ToTable(“ConfirmationFalEvent”);
builder.Entity().ToTable(“AdoptionFalEvent”);
基于模型创建(生成器);
//自定义ASP.NET标识模型,并根据需要覆盖默认值。
//例如,可以重命名ASP.NET标识表名称等。
//在调用base.OnModelCreating(builder)后添加自定义项;
builder.Entity().HasKey((e)=>new{e.ChildID,e.generalogyFalEventId,e.ParentID});
builder.Entity().HasKey(u=>new{u.CityID,u.UserID});
builder.Entity().HasKey(u=>new{u.studyfieldd,u.UserID});
}
}

为什么EF Core不创建迁移文件?

您的模型真的需要迁移吗?如果自上次迁移以来未对其进行修改,则ef可能不需要生成迁移


只是一个猜测,但不确定。

是的,我已经为我的模型创建了一个新的结构,因此在我的上下文中有了新的属性。我已删除dotnet ef数据库,但它不会生成用于重新创建数据库的文件。您是否可以尝试使用-verbose标志运行上述命令并发布该输出?在“使用上下文‘ApplicationDbContext’”之后没有输出?这可能是生成迁移的代码仍在运行的迹象(可能卡在无限循环中)我没有考虑到这一点,因为命令行在此之后没有被阻止,我编辑了我的问题,以便您可以看到ApplicationDbContext代码,不知道EF Core是否在使用我使用的复合键时崩溃?这里似乎没有任何问题。你能用完整的复制步骤和模型类来提交一个bug吗?你有没有解决过这个问题-我也有同样的问题。。。