我有一个非常简单的实体框架项目,其中包含 POCO实体。我使用stored procedure
导入了一个EF Wizard
。 KEWL。
然后我创建了自己的EF Entity
,然后我Add Function Import
将Stored Procedure
映射到我的EF Entity
。
现在......我不确定如何将EF Entity
映射到POCO
。因此,我不断收到以下错误:
错误11007:实体类型'XXXXX'是 没有映射。
我不确定如何将此实体映射到POCO
。有人可以帮忙吗?
答案 0 :(得分:6)
S'Ok。这就是我最终要做的事情。
IE中。 .edmx
,Custom Tool
被删除/没有自动生成的实体等
在您的上下文课程中......
public class SqlServerContext : ObjectContext, IUnitOfWork
{
public SqlServerContext(EntityConnection entityConnection,
ILoggingService loggingService)
: base(entityConnection) { .... }
public ObjectResult<Location> FindLocationsWithinABoundingBox(decimal upperLeftLongitude,
decimal upperLeftLatitude,
decimal lowerRightLongitude,
decimal lowerRightLatitude)
{
return base.ExecuteFunction<Location>("FindLocationsWithinABoundingBox",
new ObjectParameter("UpperLeftLatitude", upperLeftLongitude),
new ObjectParameter("UpperLeftLongitude", upperLeftLatitude),
new ObjectParameter("LowerRightLongitude", lowerRightLongitude),
new ObjectParameter("LowerRightLatitude", lowerRightLatitude));
}
}
dat's it。
不确定我的POCO方式是否是最好的做事方式,但它......好......工作:)
并this is a related StackOverflow question I asked关于以services / IQueryable方式使用此存储过程......:)