c# - Remove Auto Increment in EF 7 - RC2 -
in ef7 rc2, default, integer primary key auto increment field. tried remove it. using data annotation fluent api, nothing works.
using data annotation:
[key, column(order = 1, typename = "int"), databasegenerated(databasegeneratedoption.none)]
using fluent api:
modelbuilder.entity<tblproduct>().haskey(t => t.prodid).hasannotation("databasegenerated", databasegeneratedoption.none); //or use following modelbuilder.entity<tblproduct>().haskey(t => t.prodid).hasannotation("databasegenerated", 0); //or use following modelbuilder.entity<tblproduct>().haskey(t => t.prodid).hasannotation("sqlite:autoincrement", false);
nothing has worked :(
can please me?
updated
as requested, here table script after running add-migration localdb_v1
migrationbuilder.createtable( name: "tblproduct", columns: table => new { prodid = table.column<int>(nullable: false) .annotation("sqlite:autoincrement", true), name = table.column<string>(nullable: true), description = table.column<string>(nullable: true) }, constraints: table => { table.primarykey("pk_tblproduct", x => x.prodid); }); ... ... ...
in ef core, key , property configured separately.
to specify key:
modelbuilder.entity<tblproduct>().haskey(t => t.prodid);
to configure property not being auto increment:
modelbuilder.entity<tblproduct>().property(t => t.prodid).valuegeneratednever();
Comments
Post a Comment