What is the proper usage of HasColumnType and Database generated

c# entity-framework fluent-interface

Accepted Answer

varchar(50) is not a column type itself, 'varchar' is a data type while (50) is the maximum length of characters in a string. You must proceed in this manner.

mb.Entity<SomeObject>()
            .Property(so => so.Type)
            .IsUnicode(false)
            .HasColumnName("Type")
            .HasColumnType("varchar")
            .HasMaxLength(50)
            .IsRequired()
            .HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);

Regarding your second query, if you don't provide a GUID, the GUID setting in the database settings will be set to the default value; if you want to change it, use the GUID generator class.

12
6/15/2014 10:50:18 AM

Popular Answer

ZZZ_tmp


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow