mapping private property entity framework code first

前端 未结 7 1915
遇见更好的自我
遇见更好的自我 2020-11-27 17:23

I am using EF 4.1 and was look for a nice workaround for the lack of enum support. A backing property of int seems logical.

    [Required]
    public VenueT         


        
7条回答
  •  被撕碎了的回忆
    2020-11-27 17:38

    Try this.

      public class UserAccount
        { 
           private string Username { get; set;}
        }
    
    
    
       public class UserAccountConfiguration :IEntityTypeConfiguration
         {
           public void Configure(EntityTypeBuilder builder)
             {
               builder.Property(c => c.Username);
             }
    }
    

    and then in DbContext

    protected override void OnModelCreating(ModelBuilder modelBuilder)
      {
        modelBuilder.ApplyConfiguration(new UserAccount.UserAccountConfiguration());
      }
    

提交回复
热议问题