问题
Now that Sql Server 2012 (including SQL Server Express 2012) has SEQUENCE
feature just like Oracle as explained here, here, and here.
I can get the next sequence
like so, SELECT NEXT VALUE FOR SeqName
But how do I do that from my code using Entity Framework 5?
回答1:
I got it working using SqlQuery
like so..
int sequence = context.Database.SqlQuery<int>("SELECT NEXT VALUE FOR MySequenceName").FirstOrDefault();
来源:https://stackoverflow.com/questions/16753149/how-to-get-the-next-sequence-number-in-sql-server-express-using-entity-framework