c# - Entity Framework is trying to drop existing column -



c# - Entity Framework is trying to drop existing column -

i bit mystified entity framework behavior. have class this:

business relationship -id (pk, int, not null) -accountid (pk, int, not null) -clientid -... other scalars

the accountid field should come api consume. unfortunately, did not know @ time entity framework not back upwards non-db generated primary keys. have drop accountid part of primary key.

when remove [key] attribute accountid field, odd behavior migration. here lines migration create no sense me.

dropcolumn("dbo.account", "clientid"); renamecolumn(table: "dbo.account", name: "id", newname: "clientid"); .... more stuff altercolumn("dbo.account", "id", c => c.int(nullable: false, identity: true)); addprimarykey("dbo.account", "id");

why entity framework trying drop unrelated column (clientid)? , why trying utilize column in altercolumn statement no longer exists (id has been renamed clientid)?

you can utilize non-db generated primary key.

if doing code first can utilize attribute:

[databasegenerated(databasegenerationoption.none)] public int (or string or w/e) id { get; set; }

are trying utilize code first or database first or how trying create model? can edit reply more details if need.

c# entity-framework

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -