none
Linq to SQL issue RRS feed

  • Question

  • Posted - 09/10/2012 :  10:23:09  Show Profile  Email Poster  Edit Topic
    Reply with Quote  Delete Topic
    Nuke Spam!

    I'm getting an 'interesting' issue with this code:

    // this method is used to determine if a member name is already in use.
    public static bool Lookup( string memberName, IDataProvider db )
    {
       var id = from c in db.Identity where c.MemberName == memberName select new { c };
       return ( id.First() != null );
    }

    The ecepting being returnde is:

    The provider did not return a ProviderManifestToken string.


    My question is:

    What is a ProviderManifestToken string and how would I go about generating one?

    Background: The is running against SQL Server 2008 R2

    - Eric
    www.my-msi.net


    - Eric www.my-msi.net/Admin

    • Moved by Bob Shen Tuesday, September 11, 2012 3:33 AM (From:Visual C# General)
    Monday, September 10, 2012 8:17 PM

Answers

All replies

  • Here is the MSDN Link which explains about ProviderManifestToken



    --Krishna

    Monday, September 10, 2012 8:24 PM
  • Check your link.... it did not provide the information I need to resolve this issue!

    - Eric www.my-msi.net/Admin

    Monday, September 10, 2012 8:39 PM
  • If you read the page completely, it has information on it. copied from the link.

    Targeting the Correct SQL Server Version

    The Entity Framework targets the Transact-SQL query based on the SQL Server version that is specified in the ProviderManifestToken attribute of the Schema element in the storage model (.ssdl) file. This version might differ from the version of the actual SQL Server you are connected to. For example, if you are using SQL Server 2005, but your ProviderManifestToken attribute is set to 2008, the generated Transact-SQL query might not execute on the server. For example, a query that uses the new date time types that were introduced in SQL Server 2008 will not execute on earlier versions of the SQL Server. If you are using SQL Server 2005, but your ProviderManifestToken attribute is set to 2000, the generated Transact-SQL query might be less optimized, or you might get an exception that says that the query is not supported. For more information, see the CROSS and OUTER APPLY Operators section, earlier in this topic.

    Certain database behaviors depend on the compatibility level set to the database. If your ProviderManifestToken attribute is set to 2005 and your SQL Server version is 2005, but the compatibility level of a database is set to "80" (SQL Server 2000), the generated Transact-SQL will be targeting SQL Server 2005, but might not execute as expected due to the compatibility level setting. For example, you might lose ordering information if a column name in the ORDER BY list matches a column name in the selector.


    --Krishna

    Tuesday, September 11, 2012 9:18 PM
  • Thanks Krishnav,

    But it still leaves out the required info to actually solve this issue.

    I am targeting SQL Server 2008 R2 and every other Linq statement works correctly, it is only the provided method that has an apparent issue.

    And it should be noted that in most cases, including the test case I'm using, the memberName provided is NOT in the database!


    - Eric www.my-msi.net/Admin


    • Edited by Eric_D Tuesday, September 11, 2012 11:28 PM
    Tuesday, September 11, 2012 11:26 PM
  • Hi Eric_D,

    Welcome to MSDN Forum.

    Could you please post the inner exception here? This is so we can help you more effectively.

    After researching, I found there're many reasons will cause this issue. Below are the reasons I have found.

    1. Login fails (password expired or something else);

    2. SQL Server Service isn't running;

    3. Place the connection string within the app.config of the wrong project in Visual Studio;

    4. Check the permission.

    Here're the links which I found, please refer to them.

    http://stackoverflow.com/questions/4741499/how-to-configure-providermanifesttoken-for-ef-code-first

    http://stackoverflow.com/questions/5423278/ef-4-1-exception-the-provider-did-not-return-a-providermanifesttoken-string

    http://stackoverflow.com/questions/7446055/ef-code-first-the-provider-did-not-return-a-providermanifesttoken-string

    Please let me know if it could help. : )

    Best Regards


    Allen Li [MSFT]
    MSDN Community Support | Feedback to us

    Wednesday, September 12, 2012 2:08 AM
    Moderator
  • I can't see the connection string as the problem becuase 1) this is a very database driven site and it is only this one query that is causing the issue and 2) I really think that asking the databae to find something that does not exist (what this method is doing) is real issue here.

    If there is a better way to test for the non-existance of an item in the database, I'm all ears :-)


    - Eric www.my-msi.net/Admin

    Wednesday, September 12, 2012 3:08 PM
  • The inner exception is:

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

    The connection string is:

    "Data Source=myDB\myDB;Initial Catalog=My-MSI.Net;Persist Security Info=True;User ID=myuserid;Password=mypassword

    ProviderName="System.Data.SqlClient"

    - Eric www.my-msi.net/Admin

    Wednesday, September 12, 2012 7:48 PM
  • Hi Eric_D,

    The inner exception states clearly that connecting to the database failed. Please check the connection string. Does the Data Source exist? Or Are the User ID and Password both correct?

    Best Regards


    Allen Li [MSFT]
    MSDN Community Support | Feedback to us

    Thursday, September 13, 2012 2:42 AM
    Moderator
  • Hi Eric_D,

    Have you solved the issue? I look forward to hearing from you.

    Best Regards


    Allen Li [MSFT]
    MSDN Community Support | Feedback to us

    Monday, September 17, 2012 1:33 AM
    Moderator