I have looked at this post and tried to do it this way
Autogenerate primary key (Guid) Entity Framework CTP5
[Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public Guid CompanyID { set; get; }
However I am still getting the error
Identity column 'CompanyID' must be of data type int, bigint, smallint, tinyint, or decimal or numeric with a scale of 0, and constrained to be nonnullable.
This is when I run Update-Database command on the package manager console.
Had the same issue, the only thing helped me is dropping database to initial empty state, removing all migrations and creating a new one with proper GUID key:
Update-Database -TargetMigration:0
Add-Migration InitialCreate
Update-Database
I agree that this is not a best solution, but it was acceptable for me since I had started project a few hours before.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With