EF Code First - The Provider did not return a ProviderManifestToken string

15,307

Solution 1

The problem with answering this question is that the culprit could be more than one issue.

That said, I see a couple things to check:

  1. Your Data Source name looks to be invalid. You need to declare the host name and the instance name. Example: .\SQLEXPRESS (notice the . dot) or MyServerHostName\MySqlInstanceName.

    Verify you have a valid data source by using SQL Server Management Studio and trying it there first.

  2. Permissions. You are using integrated security and so the security context of the application making the database connection must have proper rights. Things to check:

    Using SQL Server Mgmt Studio, connect to your database. Select your database in the left pane (Object Explorer) --> Databases --> Select your db --> Security --> Users. Make sure you can verify the account being used to run the app has either been granted rights explicitly or can inherit them by being a member of the groups.

When I had this error, my problem proved to be that I had mixed Integrated Security=SSPI with a "Username =" and "Password =" ...not realizing that I needed Integrated Security=false; my user and password parameters were being ignored.

Not sure about this one: I did read some people suggest (at least for troubleshooting) to set Persist Security Info=true.

Solution 2

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.

Share:
15,307
Lance
Author by

Lance

Updated on June 07, 2022

Comments

  • Lance
    Lance almost 2 years

    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.

    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>
    

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

    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.

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

    Thanks,

    Ken

    Update

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

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