Vote UpVote

Adding a [FixedLength] Attribute in Code-First Entity Framework

Craig Stuntz's Weblog – In Code First Entity Framework models, you can define the length of a string field with StringLengthAttribute, but you have to write code in OnModelCreating to indicate a CHAR/NCHAR fixed length field: public class MyEntity { [Key] public int Id { get; set; } [StringLength(2)] public string FixedLengthColumn { get; set; } } public partial class MyContext : DbContext { public virtual DbSet MyEntities { get; set; } protected override void OnModelCreating(DbModelBuilder modelBuilder) { if (modelBuilder == null) throw new ArgumentNullException("modelBuilder"); modelBuilder.Entity() ...
Favorite? Off-Topic? Craig Stuntz @ 2015-08-17 20:26


Visits: 850
Votes: 0
Favorites: 0
Off-Topic: 1

Visits by Source

User Actions

Users who voted for this posting

Contact us to advertise on DelphiFeeds.com

Community Links

Torry Firebird News


Please login or register to use this functionality.
(click on this box to dismiss)