Search code examples
asp.net-mvc-3sqliteentity-framework-4.1ef-code-firstsystem.data.sqlite

SQLite CreateDatabase not supported error


I'm using Entity Framework 4.2 CF with SQLite, but when i try to launch the application i got "CreateDatabase is not supported by the provider" error. This is my model mapping:

protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            #region NewsMapping

            modelBuilder.Entity<News>().ToTable("news");
            modelBuilder.Entity<News>().HasKey(x => x.Id).Property(x => x.Id).HasColumnName("ID").HasColumnOrder(0);
            modelBuilder.Entity<News>().Property(x => x.Status).HasColumnName("STATUS");
            modelBuilder.Entity<News>().Property(x => x.NewsTitle).HasColumnName("NEWS_TITLE");
            modelBuilder.Entity<News>().Property(x => x.Content).HasColumnName("CONTENT_1");
            modelBuilder.Entity<News>().Property(x => x.IsImportant).HasColumnName("IS_IMPORTANT");
            modelBuilder.Entity<News>().Property(x => x.OrderNumber).HasColumnName("ORDER_NUMBER");
            modelBuilder.Entity<News>().Property(x => x.CreateDate).HasColumnName("CREATE_DATE");
            #endregion

            base.OnModelCreating(modelBuilder);

        }

What is wrong in this code?

Thanks


Solution

  • Ok i found the solution, the provider doesn't support "Database Creation", so i had to initialize it empty:

    public EkosContext()
            {
                Database.SetInitializer<EkosContext>(null);
            }