Entity Framework CTP 4. “Cannot insert the value NULL into column” - Even though there is no NULL value

前端 未结 9 1601
情深已故
情深已故 2020-12-05 06:21

Im using EF CTP 4. I have a simple console app (for testing purposes) that is using EF to insert some data into a SQL database.

I have come to a problem where by upo

9条回答
  •  执念已碎
    2020-12-05 06:56

    In my case EntityFramework generated this code inside Context.cs class:

    modelBuilder.Entity(entity =>
    {
        entity.Property(e => e.Id).ValueGeneratedNever(); // <= this line must remove
        ...
    }
    

    after remove this line, problem solved.

提交回复
热议问题