EntityFrameWork添加功能:无法加载指定的元数据资源

EntityFrameWork Add function: Unable to load the specified metadata resource

我正在使用 Sql server 2014 并创建了一个 ADO.NET 实体数据模型。它生成了这个模型:

我正在尝试将检索到的邮件添加到我的数据库中。它看起来像这样:

    public int StoreMail(PhishingMail PhishingMail)
    {
        using (var phishingMailStorage = new PhishFinderDB2Entities2())
        {
          //  phishingMailStorage.Database.Connection.Open();

            phishingMailStorage.PhishingMail.Add(PhishingMail);
            phishingMailStorage.SaveChanges();
        }
        return PhishingMail.PhishingMailId;
    }

每当我调试程序时。我卡在这部分了:

phishingMailStorage.PhishingMail.Add(PhishingMail);

It gives me the metadataexception was unhandeld exception:An unhandled exception of type 'System.Data.Entity.Core.MetadataException' occurred in EntityFramework.dll Additional information: Unable to load the specified metadata resource.

这是我的连接字符串: 我真的不知道它为什么会产生这个巨大的字符串。这可能会导致问题。

<add name="PhishFinderDB2Entities2" connectionString="metadata=res://*/DataAccess.PhishFinderModel.csdl|res://*/DataAccess.PhishFinderModel.ssdl|res://*/DataAccess.PhishFinderModel.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=WIN7DEV;initial catalog=PhishFinderDB;integrated security=True;pooling=False;multipleactiveresultsets=True;application name=EntityFramework&quot;" providerName="System.Data.EntityClient" /><add name="PhishFinderDB2Entities" connectionString="metadata=res://*/DataAccess.PhishFinderModel.csdl|res://*/DataAccess.PhishFinderModel.ssdl|res://*/DataAccess.PhishFinderModel.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=(local);initial catalog=PhishFinderDB2;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" /><add name="PhishFinderDB2" connectionString="metadata=res://*/DataAccess.Model1.csdl|res://*/DataAccess.Model1.ssdl|res://*/DataAccess.Model1.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=WPNLL0038874\SQLEXPRESS;initial catalog=PhishFinderDB2;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" /></connectionStrings>

你知道我为什么会得到这个异常吗? 谢谢

尝试删除生成的PhishFinderDB2.edmx(如果您自行调整,请记住保存数据)。 同时删除连接字符串。 然后重新生成整个 PhishFinderDB2 ado.net 模型。 对我来说这帮助了很多次。