Sql server 使用EF core从DB获取数据时忽略实体的额外属性
我正在使用EF核心。而我想使用存储过程和EF核心从数据库中提取数据。对于那些未从DB返回的属性,我得到了一个错误。我怎样才能修好它 实体:Sql server 使用EF core从DB获取数据时忽略实体的额外属性,sql-server,asp.net-core,entity-framework-core,asp.net-core-webapi,Sql Server,Asp.net Core,Entity Framework Core,Asp.net Core Webapi,我正在使用EF核心。而我想使用存储过程和EF核心从数据库中提取数据。对于那些未从DB返回的属性,我得到了一个错误。我怎样才能修好它 实体: public class CustomOverview { public int A{ get; set; } public int? B{ get; set; } public int? C{ get; set; } public int? D{ get; set; } } 存储库代码 public async T
public class CustomOverview
{
public int A{ get; set; }
public int? B{ get; set; }
public int? C{ get; set; }
public int? D{ get; set; }
}
存储库代码
public async Task<CustomOverview> GetMyData()
{
return _dbContext.CustomOverviews.FromSqlInterpolated($"exec spr_myStoreProcedure).AsEnumerable().FirstOrDefault();
}
我怎样才能解决它。有许多解决方案建议删除属性或在属性之前使用[NotMapped]属性。但我的要求是,我需要这些属性用于不同的存储过程。所以我没法把它们移走
InvalidOperationException: The required column 'C' was not present in the results of a 'FromSql' operation.