Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 344
mehmetserif Avatar asked Dec 03 '22 05:12

mehmetserif


1 Answers

Nothing is wrong in the code. The error says exactly what is going on. Your EF provider for SQLite (System.Data.SQLite) doesn't provide database creation so you must create database and all tables manually before you launch the application.

like image 107
Ladislav Mrnka Avatar answered Dec 24 '22 14:12

Ladislav Mrnka