SQLite的CreateDatabase用于不支持错误 [英] SQLite CreateDatabase not supported error

查看:1719
本文介绍了SQLite的CreateDatabase用于不支持错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用实体框架4.2 CF使用SQLite,但是当我尝试启动我得到了应用程序错误的CreateDatabase不是由供应商支持。这是我的模型映射:

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

        }

什么是错的这个code?

What is wrong in this code?

感谢

推荐答案

好吧,我找到了解决办法,提供者不支持数据库创建,所以我不得不将其初始化空的:

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

这篇关于SQLite的CreateDatabase用于不支持错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆