ADO.NET Entity Framework 之“无法加载指定的元数据资源。”
修改了ef项目的连接字符串后,运行程序出现 "无法加载指定的元素数据资源"
原因是连接字符串中csdl/.ssdl/.msl三个文件的路径没有修改
连接前的字符串:
<add name="UserRightContext" connectionString="metadata=res://*/UserRight.csdl|res://*/UserRight.ssdl|res://*/UserRight.msl;provider=System.Data.SqlClient;provider connection string="Data Source=PC2012030213UMH\SQLEXPRESS;Initial Catalog=SjlFramework;User ID=sa;MultipleActiveResultSets=True"" providerName="System.Data.EntityClient" />
连接后的字符串:
View Code
<add name="UserRightContext"
connectionString="metadata=res://*/App_Code.Model.csdl|res://*/App_Code.Model.ssdl|res://*/App_Code.Model.msl;provider=System.Data.SqlClient;provider connection string="Data Source=PC2012030213UMH\SQLEXPRESS;Initial Catalog=SjlFramework;Integrated Security=True;MultipleActiveResultSets=True"" providerName="System.Data.EntityClient"/>
connectionString="metadata=res://*/App_Code.Model.csdl|res://*/App_Code.Model.ssdl|res://*/App_Code.Model.msl;provider=System.Data.SqlClient;provider connection string="Data Source=PC2012030213UMH\SQLEXPRESS;Initial Catalog=SjlFramework;Integrated Security=True;MultipleActiveResultSets=True"" providerName="System.Data.EntityClient"/>
更改模型命名空间一定不要忘了在App.Config中更改.csdl/.ssdl/.msl三个文件的路径
多思考,多创新,才是正道!