简体   繁体   English

EF 5.0-生成的POCO包含System.Data.Spatial.DbGeography类型

[英]EF 5.0 - Generated POCO's contain System.Data.Spatial.DbGeography type

I have two c# projects, one containing the edmx file (db first approach) and a second one (POCO-Project) to where the POCO's (DAO's) are generated. 我有两个c#项目,一个包含edmx文件(db第一种方法),第二个包含POCO项目(DAO)的第二个项目(POCO-Project)。 I want to use the classes of the poco project in the UI and Business Layer. 我想在UI和业务层中使用poco项目的类。

My problem is, that some of the generated POCO's contain properties of type 我的问题是,某些生成的POCO包含类型为

System.Data.Spatial.DbGeography System.Data.Spatial.DbGeography

And I don't want the POCO project to be tight to System.Data.dll. 而且我不希望POCO项目与System.Data.dll紧密相关。 Can I tell EF to generate an System.Data independent object for 我可以告诉EF为之生成System.Data独立对象吗

System.Data.Spatial.DbGeography System.Data.Spatial.DbGeography

Or what would be a viable work around? 还是可行的解决方案? I don't want to force other projects to add a reference to System.Data.dll 我不想强迫其他项目添加对System.Data.dll的引用

Based on your needs I would consider implementing a DTO(basically another POCO) for DbGeography where you can hold all the data stored within System.Data.Spatial.DbGeography. 根据您的需求,我会考虑为DbGeography实现DTO(基本上是另一个POCO),在其中您可以保存System.Data.Spatial.DbGeography中存储的所有数据。 That way you keep all the data without the reference to System.Data. 这样,您无需参考System.Data就可以保留所有数据。 But this comes at a price, you'll have to make sure the data is correctly tranfered from the actual DbGeography to your DTO and you'll lose all the methods of DbGeography. 但这是有代价的,您必须确保将数据从实际的DbGeography正确传输到您的DTO,并且您将丢失所有DbGeography的方法。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 从对象类型System.Data.Spatial.DbGeography到已知的托管提供程序本机类型不存在映射 - No mapping exists from object type System.Data.Spatial.DbGeography to a known managed provider native type 异常:不存在从对象类型System.Data.Spatial.DbGeography到已知托管提供程序本机类型的映射 - Exception : No mapping exists from object type System.Data.Spatial.DbGeography to a known managed provider native type Peta Poco和System.Data.Entity.Spatial.DbGeography - Peta Poco and System.Data.Entity.Spatial.DbGeography 无法映射到基本类型的“ System.Data.Entity.Spatial.DbGeography”的属性类型 - Property type of 'System.Data.Entity.Spatial.DbGeography' which cannot be mapped to a primitive type System.Data.Spatial DbGeography.Distance单位? - System.Data.Spatial DbGeography.Distance units? System.Data.Entity.Spatial.DbGeography-没有无参数构造函数 - System.Data.Entity.Spatial.DbGeography - No Parameterless Constructor System.Data.Entity.Spatial.DbGeography带有标高的距离 - System.Data.Entity.Spatial.DbGeography Distance with elevation System.Data.Spatial DbGeography.Distance不能始终如一地工作 - System.Data.Spatial DbGeography.Distance is not working consistantly 将 System.Data.Entity.Spatial.DbGeography 绑定到 MVC Model - Bind System.Data.Entity.Spatial.DbGeography to MVC Model Dapper无法将“Microsoft.SqlServer.Types.SqlGeography”类型的对象强制转换为“System.Data.Entity.Spatial.DbGeography” - Dapper unable to cast object of type 'Microsoft.SqlServer.Types.SqlGeography' to type 'System.Data.Entity.Spatial.DbGeography'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM