2014-06-11 48 views
4

我正在使用.NET 4.0项目。我安装了EF -version 6.0.0 nuget软件包。EF 6.0.0 - 从头创建数据库

我添加了一个类库,安装EF,然后启用迁移,添加我的DB Context类,和我的App.config里面,我说这个配置部分:当我运行应用程序

<contexts> 
    <context 
    type="DataLayer.MiddlewareDbContext, DataLayer"> 
    <databaseInitializer 
     type="System.Data.Entity.MigrateDatabaseToLatestVersion`2[[ 
     DataLayer.MiddlewareDbContext, DataLayer], 
     [DataLayer.Migrations.Configuration, DataLayer]], EntityFramework" /> 
    </context> 
</contexts> 

,我得到以下例外,当我尝试访问DB语境:

Method not found: 'System.Data.Entity.Migrations.Model.ColumnModel System.Data.Entity.Migrations.Builders.ColumnBuilder.String(System.Nullable`1<Boolean>, System.Nullable`1<Int32>, System.Nullable`1<Boolean>, System.Nullable`1<Boolean>, System.String, System.String, System.String, System.String, System.Collections.Generic.IDictionary`2<System.String,System.Data.Entity.Infrastructure.Annotations.AnnotationValues>)'. 

还要注意,不被创建的数据库!

Migrations文件夹已经包含一个迁移文件,其中包含我拥有+ Configuration类的所有模型。

欣赏检查了这一点。

问候

+0

您是否设法解决这个问题?我在迁移数据库时遇到了这个确切的错误。 –

回答

3

时的EntityFramework的多个版本已经通过的NuGet安装在同一个解决方案不同的项目可能会发生此行为。

这可以通过打开解决方案的包管理器,选择最新版本的EntityFramework,单击管理,然后选择所有项目来解决。然后这将更新所有旧版本到相同的版本。

+1

钉钉! EF项目中的V6.1.1和Web项目中的V6.0.0在同一解决方案中。顺便说一句:在VS2013项目的工作。当我在VS2015中打开它时,问题就开始了。 – Axeman

相关问题