I am transferring the substantial EF model ~ 80 entites from EF4 to EF6, and I am also changing it from the database created by Designer EDMX to the Code First database.
Right now I'm setting up entity relationships using EF fluent-api, and I'm not sure if I am doing this correctly.
This type is in the varchar(50) SQL Server database, so what should I configure it like that?
mb.Entity<SomeObject>() .Property(so => so.Type) .IsUnicode(false) .HasColumnName("Type") .HasColumnType("varchar") .HasMaxLength(50) .IsRequired() .HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);
or how is it without HasMaxLength(50) ?
mb.Entity<SomeObject>() .Property(crt => crt.Type) .IsUnicode(false) .HasColumnName("Type") .HasColumnType("varchar(50)") .IsRequired() .HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);
Also, let's say I have another object with a GUID:
mb.Entity<AnotherObject>() .Property(ao => ao.ID) .HasColumnName("ID") .HasColumnType("uniqueidentifier") .IsRequired() .HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);
In the database, it has a default value of newsequentialid() , should I configure it using DatabaseGeneratedOption.None , DatabaseGeneratedOption.Identity or DatabaseGeneratedOption.Computed ?
What is the difference between these options? In addition, in the code, in most cases, GUIDs are assigned when creating an object, for example:
Guid ID = new Guid.NewGuid()
Respectively?