“Unknown data type” error with Firebird embedded and Entity Framework 6

前端 未结 1 761
别跟我提以往
别跟我提以往 2021-01-20 13:02

I\'m using an embedded Firebird database with code first (Entity Framework 6). The first time the application runs, it works fine: the database gets created and the data ge

相关标签:
1条回答
  • 2021-01-20 13:30

    I Had the same problem, The Entity initializer is bugged with Firebird embedded:

    Database.SetInitializer<FirebirdDbContext>(new CreateDatabaseIfNotExists<FirebirdDbContext>()); 
    

    is the problem, change it to:

    Database.SetInitializer<FirebirdDbContext>(null);
    

    But it will not create the database for you. You could check if the database file existis then change de initializer.

    or you can create your initializer that does tha same, and works:

    public class MyCreateDatabaseIfNotExists : IDatabaseInitializer<FirebirdDbContext>
    {
        public void InitializeDatabase(FirebirdDbContext context)
        {
            if (!context.Database.Exists())
            {
                context.Database.Create();
            }
        }
    }
    
    0 讨论(0)
提交回复
热议问题