为什么在Entity Framework Dll中的TableAttribute? [英] Why is the TableAttribute in the Entity Framework Dll?
问题描述
这不妨碍您创建一个简单包含您的实体的Domain项目,而不依赖于特定的数据访问技术?例如,如果我使用这个属性,我不相信这些类可以移植到Silverlight。
这是一个监督,还是我缺少某些东西? >
我意识到我可以使用流畅的API来规避这一点,但是这个属性似乎更适合这个目的。
我认为是因为在4.1中添加了TableAttribute。它属于命名空间 System.ComponentModel.DataAnnotations
,可能已经添加到 System.ComponentModel.DataAnnotations.dll
程序集如果EF 4.1已经是常规.NET Framework版本的一部分。但是因为EF 4.1是独立于Framework更新而发布的,所以它们无法触及框架核心程序集。所以,现在在EntityFramework.dll中,但仍然在 System.ComponentModel.DataAnnotations
命名空间中,所以不知何故独立于实体框架。也许它将被移动到 System.ComponentModel.DataAnnotations.dll
与下一个.NET Framework版本。
现在,如果要使用TableAttribute装饰您的POCO,则必须引用EntityFramework.dll。只要您不在自定义程序集中使用真实的EF东西( DbContext
等),我不会将其视为实体框架的依赖项。 / p>
Is there a good reason why the Table attribute (which can be used to map a POCO class to the correct database name/schema) is in the EntityFramework.dll?
Doesn't this prevent you from creating a Domain project that simply contains your entities with no dependency on a specific data access technology? For example, if I use this attribute I don't believe the classes would be portable to Silverlight.
Is this an oversight, or am I missing something?
I realize I could use the fluent API to circumvent this, but the attribute seems preferable for this purpose.
I think because the TableAttribute has been added in EF 4.1. It belongs to namespace System.ComponentModel.DataAnnotations
and would probably have been added to System.ComponentModel.DataAnnotations.dll
assembly if EF 4.1 had been part of a regular .NET Framework release. But because EF 4.1 was released independently from a Framework update they couldn't touch the framework core assemblies. So, it is for now in EntityFramework.dll but still in System.ComponentModel.DataAnnotations
namespace, so somehow independent from Entity Framework. Maybe it will be moved into System.ComponentModel.DataAnnotations.dll
with the next .NET Framework version.
For now, if you want to decorate your POCOs with the TableAttribute you must reference EntityFramework.dll. I wouldn't consider this as dependency from Entity Framework as long as you don't use the "real" EF stuff (DbContext
, etc.) in your custom assembly.
这篇关于为什么在Entity Framework Dll中的TableAttribute?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!