I have entity in C# that has Id column. This is Primary key. But I don't to have it as Identity column. I want to assign value to Id column in my code in C#. Entity:
public class MasterReview
{
public int Id { get; set; }
In database I have column Id, Identity Specification is set as no. In C# when I add new entity I set value to Id:
public void Add(int reviewId, string title, string language, string assignee)
{
using (var uow = unitOfWorkFactory.CreateUnitOfWork())
{
uow.MasterReviewRepository.Add(new Models.MasterReview()
{
Id = reviewId,
Title = title,
Language = language,
Assignee = assignee
});
uow.Save();
}
}
And when I call uow.Save
I get error:
Cannot insert the value NULL into column 'Id', table 'MyApp.dbo.MasterReview'; column does not allow nulls. INSERT fails.
Value is set, is not empty. It's 3.