在db中存储没有任何唯一属性的类。 [英] Store class without any unique property in db.

查看:62
本文介绍了在db中存储没有任何唯一属性的类。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用EF4.0在DB中存储预定义的.Net框架类。

I want to store predefined .Net framework class in DB using EF4.0.

类没有任何唯一标识符(属性)。

Class doesn`t have any unique identifier(property).

我使用代码优先方法。

当我插入这样的实体时,有没有办法在db中自动生成Id。

Is there any way to autogenerate Id in db when i insert such entity.

I不要担心Id被映射到实体。

I don`t bother about Id being mapped to entity.

推荐答案

您始终可以在数据库中添加标识列。  但是,您必须在EF中为您的实体添加匹配属性。
You can always add an identity column in the db.  However, you will have to add a matching property on your entity in EF.


这篇关于在db中存储没有任何唯一属性的类。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆