Entity Framework - Unable to load the specified metadata resource

前端 未结 17 1251
一生所求
一生所求 2020-12-14 15:21

I realise that this has been asked a number of times but I just can\'t seem to get the bottom of my issue. I\'m getting the following error stack:

相关标签:
17条回答
  • 2020-12-14 15:48

    If you're trying to use more than one EDMX file and you have to put your new EDMX file in it's own namespace due to conflicts, when creating the EDMX file take note of the metadata the wizard shows you. That one is the correct one.

    Then later if you are using EntityConnectionStringBuilder and are setting the Metadata there make sure you take into account the new namespace.

    None of the answers here helped me as I had: /EDMX1 /Namespace/EDMX2

    and while the metadata for the EDMX1 is "edmx1.csdl|edmx1.ssdl|edmx1.msl" The metadata for EDMX2 is "Namespace.edmx2.csdl ..."

    0 讨论(0)
  • 2020-12-14 15:51

    I was having the same issue

    System.Data.MetadataException: Unable to load the specified metadata resource

    It turned out the Connection string which was generated earlier had all the edmx's name on it. I took out all the model names from the connection string leaving only the below string in my metadata

    "metadata=res://*/;provider=System.Data.SqlClient;provider
    

    This worked for me.

    0 讨论(0)
  • 2020-12-14 15:53

    you should specify the assembly fully qualified name and a path to your model file within it(separated by /), not the dll name

    connectionString="metadata=res://Name.Of.The.Assembly, Culture=neutral, PublicKeyToken=8e2e51fcf4cf363e/Payment.PaymentModel.csdl|.........."
    

    the same for ssdl and msl

    0 讨论(0)
  • 2020-12-14 15:55

    I am sharing my code with another developer and he had this problem.No connection string differences. All the files OK... I fixed it by setting

    • Metadata Artifact Processing from: "Embed in Output Assembly" to "Copy to output directory" ,
    • rebuilding the project,
    • and then setting it back again.

    This worked, I assume, because the individual files (CSDL/MSL/SSDL files) were created in the output directory when it used "copy to output directory". Apparently there was a bug that required them for the embedded version to work. Hope this helps :)

    0 讨论(0)
  • 2020-12-14 15:56

    I've hit this several times when moving between development machines after pulling down code from source control. I usually just have to explicitly rebuild the project with the EDMX file in it.

    0 讨论(0)
  • 2020-12-14 15:57

    Change the metaData

    connectionString="metadata=res://*/Entities.csdl|res://*/Entities.ssdl|res://*/Entities.msl;
    

    To

    connectionString="metadata=res://*/;
    

    The above change will fix the issue

    0 讨论(0)
提交回复
热议问题