<configuration> <connectionStrings> <add name="NorthwindEntities" connectionString="metadata=res://*/NorthwindDB.csdl|res://*/NorthwindDB.ssdl|res://*/NorthwindDB.msl; provider=System.Data.SqlClient;provider connection string="Data Source=localhost;Initial Catalog=Northwind;Integrated Security=True;MultipleActiveResultSets=True""providerName="System.Data.EntityClient" /> </connectionStrings> </configuration> 需要将上面connectionStrings 配置节中的* 修改为Class Library 项目的Assembly Name。修改后的示例App.config 如下: <configuration> <connectionStrings> <add name="NorthwindEntities" connectionString=" metadata= res://NorthwindEDM/NorthwindModel.csdl|res://NorthwindEDM/NorthwindModel.ssdl|res://NorthwindEDM/NorthwindModel.msl; provider=System.Data.SqlClient;provider connection string="Data Source=localhost;Initial Catalog=Northwind;Integrated Security=True;MultipleActiveResultSets=True""providerName="System.Data.EntityClient" /> </connectionStrings> </configuration The problem sometimes occurs with the Entity Framework where it gives an array of errors when doing simple operations. For example, I received an error about not being able to “unable to load the specified metadata resource”. Uh, the connection string information is right in the config file! The problem often can be resolved simply by: open the EDMX file in the designer mode go to the properties of the EDMX set the Metadata Artifact Processing property to “Copy to Output” build the project 然后从输出目录将*.msl.*.ssdl,*.csdl文件拷贝到应用程序目录底下即可。呵呵(估计很多人这里出错!) 相关文章: