EF代码优先-提供商未返回ProviderManifestToken字符串 [英] EF Code First - The Provider did not return a ProviderManifestToken string

查看:172
本文介绍了EF代码优先-提供商未返回ProviderManifestToken字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图运行一个非常简单的EF Code First示例,但遇到了上述问题.我在这里遵循了建议(如何为EF代码优先配置ProviderManifestToken ),但无济于事.最终,我通过将实际的连接字符串而不是我定义的连接字符串名称传递给了DBContext,从而获得了EF来创建数据库和表.

I'm trying to get a very simply EF Code First example running but ran into the above problem. I've followed the advice here ( How to configure ProviderManifestToken for EF Code First ) but to no avail. I finally managed to get EF to create my database and tables by passing the actual connection string to the DBContext instead of the connection string name I had defined.

这是我最初在app.config中由连接字符串定义的方式

Here is how I defined by connection string initially in app.config

<connectionStrings>
    <add name="ProductContext" 
         connectionString="integrated security=SSPI;
                           data source=MYMACHINE;
                           persist security info=False;
                           initial catalog=Product"
         providerName="System.Data.SqlClient" />
</connectionStrings>

名称"ProductContext"与类ProductContext相匹配,并且数据库Product不存在.

The name "ProductContext" matches the class ProductContext and the database Product does not exist.

按照上一个线程的建议,我将连接字符串名称传递给ProductContext和基本DBContext cstor.这也不起作用.

Following the advice on a previous thread I passed the connection string name to ProductContext and the base DBContext cstor. This did not work either.

最后,我改而通过了上面的连接字符串,并且一切正常,创建了数据库和表.

Finally, I passed the connection string above instead and everything worked, the db was created and the tables.

我正在使用SQL Server 2008和EF 4.1.关于我在做什么错的任何想法吗?

I'm using SQL Server 2008 and EF 4.1. Any ideas as to what I'm doing wrong?

谢谢

更新

该应用程序是WPF应用程序,而不是Web应用程序.从 app.config 中删除连接字符串后,我得到相同的异常:

The application is a WPF application, not a web application. I get the same exception after I remove the connectionstring from app.config:

与网络相关或特定于实例的错误发生在 建立与SQL Server的连接.找不到服务器或 无法访问.验证实例名称正确,并且 SQL Server配置为允许远程连接. (提供者:SQL 网络接口,错误:26-错误定位服务器/实例 指定)"

"A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)"

推荐答案

我在EF6 VS 2013上遇到了类似的问题,当我在实体框架上选择保存密码" 时,此问题已解决.工程师代码优先-连接属性对话框.希望这对某人有帮助.

I had similar problem on EF6 VS 2013, the problem got solved, when I choose 'Save Password' on Entity Framework - Reverse Engineer Code First - Connection Properties Dialog. Hope this helps someone.

这篇关于EF代码优先-提供商未返回ProviderManifestToken字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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