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

前端 未结 1 762
别跟我提以往
别跟我提以往 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(new CreateDatabaseIfNotExists()); 
    

    is the problem, change it to:

    Database.SetInitializer(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
    {
        public void InitializeDatabase(FirebirdDbContext context)
        {
            if (!context.Database.Exists())
            {
                context.Database.Create();
            }
        }
    }
    

    0 讨论(0)
提交回复
热议问题