【发布时间】:2016-10-04 02:14:37
【问题描述】:
是的,我确实阅读并尝试了entity framework Unable to load the specified metadata resource
我通常首先使用代码并且没有遇到任何问题。但是我需要使用EDMX 对项目进行故障排除
上下文:
public partial class x500Entities : DbContext
{
public x500Entities()
: base("name=x500Entities")
{
}
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
throw new UnintentionalCodeFirstException();
}
public virtual DbSet<WorkerPublicExtended> WorkerPublicExtendeds { get; set; }
}
连接字符串:
<add name="x500Entities"
connectionString="metadata=res://*/CDISWorkerPublicExtended.csdl|res://*/CDISWorkerPublicExtended.ssdl|res://*/CDISWorkerPublicExtended.msl;provider=System.Data.SqlClient;provider connection string="data source=xserver;initial catalog=x500;persist security info=True;user id=xuser;password=xpassword;MultipleActiveResultSets=True;App=EntityFramework""
providerName="System.Data.EntityClient"/>
错误:
EntityFramework.dll 中出现“System.Data.Entity.Core.MetadataException”类型的异常,但未在用户代码中处理 附加信息:无法加载指定的元数据资源。
点击这条线:
return context.WorkerPublicExtendeds.FirstOrDefault(x => x.upperIDSID == idsid.ToUpper().Trim());
完整方法:
public WorkerPublicExtended GetEmployee(string idsid)
{
using (x500Entities context = new x500Entities())
{
return context.WorkerPublicExtendeds.FirstOrDefault(x => x.upperIDSID == idsid.ToUpper().Trim());
}
}
- 为什么会这样?
- 我连接到 sql server ssms,但没有看到我在图表 edmx 和模型中看到的表
WorkerPublicExtended,我看不到该名称在哪里被转换为真实的表名。这是怎么回事?
【问题讨论】:
标签: c# .net entity-framework edmx edmx-designer