簡體   English   中英

實體框架核心未創建遷移文件

[英]Entity framework core doesn't create migration file

我已經完成了模型結構並運行了

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});

    }
}

EF Core為什么不創建遷移文件?

您的模型真的需要遷移嗎? 如果自從上次遷移以來未進行修改,則ef可能不需要生成遷移。

只是不確定而已。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM