我们如何在EntityFramework CodeFirst中将身份增加2(2)? [英] How could we set an Identity incremented by two(2) in EntityFramework CodeFirst?

查看:75
本文介绍了我们如何在EntityFramework CodeFirst中将身份增加2(2)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是CodeFirst的新手。

我想创建一个表如下:



I am new to CodeFirst.
I wish to create a Table as follows:

Create Table [dbo].[UserAccount]
(
[UserID] int Identity(1,2),
[Email] nvarchar(50),
[UserName] nvarchar(50),
[Password]nvarchar(50),
Constraint [PkUserAccount] Primary Key([UserID]),
Constraint [UkEmail] Unique([Email]),
Constraint [UkUserName] Unique([UserName])
)
Go









如何使用EF5 codefirst方法创建这样的表?





How could I create such table using EF5 codefirst approach?

推荐答案

CREATE SEQUENCE TEST_Sequence
    AS INT
    START WITH 1
    INCREMENT BY 1
    MINVALUE 0
    NO MAXVALUE
   NO CACHE





这只是我找到的例子这里[ ^ ] br />




这是其他例子

http://sqlity.net/en/792/the-gap-in-the-identity-value-sequence/ [<一个href =http://sqlity.net/en/792/the-gap-in-the-identity-value-sequence/\"target =_ blanktitle =New Window> ^ ] br />




https://connect.microsoft.com/SQLServer/feedback/details/739013/failover-or-restart-results-in-reseed-of-identity [ ^ ]





http://stackoverflow.com/questions/3100129/auto-increment-over-multiple-identity-columns-in -ms-sql-2005-or-2008 [ ^ ]



http://stackoverflow.com/questions/15823814/multiple-identity-columns-or-a-way-自动增量 [ ^ ]





http://www.sqlservercentral.com/Forums/Topic1472198-1292-1.aspx [ ^ ]

:)



this is just example i found here[^]


this are othere examples
http://sqlity.net/en/792/the-gap-in-the-identity-value-sequence/[^]


https://connect.microsoft.com/SQLServer/feedback/details/739013/failover-or-restart-results-in-reseed-of-identity[^]


http://stackoverflow.com/questions/3100129/auto-increment-over-multiple-identity-columns-in-ms-sql-2005-or-2008[^]

http://stackoverflow.com/questions/15823814/multiple-identity-columns-or-a-way-to-auto-increment[^]


http://www.sqlservercentral.com/Forums/Topic1472198-1292-1.aspx[^]
:)


这篇关于我们如何在EntityFramework CodeFirst中将身份增加2(2)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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