English 中文(简体)
实体框架中的实体能否继承一个未绘制成表格的实体?
原标题:Can entities in Entity Framework inherit from an entity that is not mapped to a table?

我正在利用实体框架POCO生成一些自我跟踪的数据物体,我从全球合作框架的服务接口中排除这些物体。

我有实体A & 实体B,这两者都向数据库的不同表格绘制了地图。

我希望实体协会和实体B能够继承一个基本实体类别,以便我能够实施一个简单的世界合作框架服务接口,例如:

void Save(Entity entity)
IEnumerable<Entity> GetEntities()
void Delete(Entity entity)

在实体框架设计员中,我增加一个称为实体和实体A &的实体;实体B继承实体。 然而,实体框架抱怨,实体没有关键,没有在数据库中绘制成表格。

我能否给这两个实体提供一个没有在数据库中代表的基类?

提前感谢!

最佳回答

象我这样,我设法回答我自己的问题!

This is simply done with partial classes: 1. Define the Entity class yourself in code. 2. Create a partial class for EntityA and make it inherit from Entity.

And voila! 它的工作:-

问题回答

暂无回答




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签