问题描述
我正在尝试使用Entity Framework 6.0.2 for SQL Server Compact(代码优先)向项目添加迁移(第一次)。应用程序与数据库通信没有问题。迁移失败并显示错误消息:
I am trying to add a migration (for the first time) to a project using Entity Framework 6.0.2 for SQL Server Compact (code first). The application is having no problems communicating with the database. The migration is failing with the error message:
该项目从未引用过 code>(+/-删除对3.5的引用)?谢谢。
Does anyone know how I can force migrations to use SqlServerCe.4.0 (+/- remove the reference to 3.5)? Thank you.
编辑
非常感谢Sql Server Compact先生(ErikEJ)的建议。
Edit
Many Thanks to Mr Sql Server Compact (ErikEJ) for his suggestions.不幸的是,删除绑定重定向节点只会导致:
unfortunately, removing the binding redirect node just results in:
您绝对正确-该项目是使用私有部署。 System.Data.SqlServerCe和System.Data.SqlServerCe.Entity的引用程序集版本均为4.0.0.1
You are absolutely correct - this project is using private deployment. Referenced assembly versions for System.Data.SqlServerCe and System.Data.SqlServerCe.Entity are both to 4.0.0.1
我需要按照erik的建议删除绑定重定向节点,并将提供程序添加到应用程序配置的EntityFramework节点(该应用程序使用提供程序服务的基于代码的配置,因此这些不是
I needed to remove the binding redirect node, as suggested by erik, AND add the provider to the EntityFramework node of the app config (the application uses code-based configuration of the provider services, so these were not included) as below
<providers> <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" /> <provider invariantName="System.Data.SqlServerCe.4.0" type="System.Data.Entity.SqlServerCompact.SqlCeProviderServices, EntityFramework.SqlServerCompact" /> </providers>
推荐答案
删除绑定重定向。似乎您正在尝试使用私人部署,但您使用的是正确的System.data.SqlServerCe.dll(检查程序集版本)。如果它是4.0.0.0而不是4.0.0.1,则更改为DbProviderfactories设置以指向正确的程序集版本
Remove the binding redirect. It looks like you are trying to use private deployement, but are you using the correct System.data.SqlServerCe.dll (check the Assembly version). if it is 4.0.0.0 and not 4.0.0.1, then change to DbProviderfactories setting to point to the correct assembly version
这篇关于实体框架代码优先迁移在错误的提供程序上失败(3.5而不是4.0)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!