开发者

Entity Framework 4.1 The provider did not return a ProviderManifestToken string Exception

I downloaded the Asp.NET MVC 3 EntityFramework Code first sample application in vb.net and modified the connection string as I don't have SQL Server Express Edition to try it with Sql Server 2008 Web Edition

<add name="ApplicationServices"
         connectionString="Server=MyPC\Sql2008;Trusted_Connection=True;MultipleActiveResultSets=True"
         providerName="System.Data.SqlClient" />

when I try to run the application then ProviderIncompatibleException exception is thrown. And following error is displayed in the browser window.

Server Error in '/' Application.

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 correc开发者_C百科t and that SQL Server is configured to allow remote connections. (provider: Shared Memory Provider, error: 40 - Could not open a connection to SQL Server)

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Data.SqlClient.SqlException: 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: Shared Memory Provider, error: 40 - Could not open a connection to SQL Server)

Source Error:

Line 24: Line 25: Line 26: @For Each item In Model Line 27: @ Line 28:

Source File: C:\Documents and Settings\Shishir Shukla\My Documents\Downloads\CodeFirstEFVB\CodeFirstMVC\Views\Blog\Index.vbhtml Line: 26

The connection string which I have used works perfectly with my asp.net webforms application and also Winforms application.

Please help me soon to get rid of this problem as I have just switched to MVC.


The problem was with the connection string , I changed it to this and it worked ..

<add name="DBCon" connectionString="Data Source=.\SQL2008;Initial Catalog=TestDB;Integrated Security=True" providerName="System.Data.SqlClient" />


Can you provide a link to the project you downloaded?

You are using Windows Authentication, does the IIS account have permissions to the db?

Finally, verify your dbContext class is named "ApplicationServices". Otherwise, you may need to use the constructor that takes in a nameOrConnectionString.


Your connection string is a valid SQL connection string, but you need an Entity Framework connection string.

When you create your EF Model, create a new connection string from scratch. That will resolve this issue.

You can look at the new conneciton in your web.config, and you wil see that an Entity connection contains additional metadata as part of the connection string, and wraps the SQL conneciton string.

UPDATE:

A valid Entity connection string will look something like this:

<add name="MyDatabaseEntities" connectionString="metadata=res://*/Models.MyDatabase.csdl|res://*/Models.MyDatabase.ssdl|res://*/Models.MyDatabase.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=SERVER;initial catalog=MyDatabase;persist security info=True;user id=userid;password=password;multipleactiveresultsets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" />

However, you should let Visual Studio build the connection string for you.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜