Base solution for your next web application
Open Closed

Is it possible to create entity without Id column ? #3622


User avatar
0
itbmo created

Is it possible to create entity without Id column ? How ?

Basically we have an entity with composite key and the records are deleted and entered frequently, that means if we have identity primary key the key values will be increased drastically on frequent add/delete records. So we do not want any identity primary key for that entity, just composite key as a primary key.


3 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    You can ignore Id field in OnModelCreating of your dbContext. Should be soething like this:

    modelBuilder.Entity<Entity>().Ignore(t => t.Propert);
    

    Thanks.

  • User Avatar
    0
    itbmo created

    Exactly what i was looking for, thanks for the reply and solution.

  • User Avatar
    0
    alper created
    Support Team

    Thanks for your feedback