Created
June 2, 2020 12:20
-
-
Save mrstebo/59c7ecf1261ba720acd8b384e6c47e66 to your computer and use it in GitHub Desktop.
entity-framework-model-mapping-3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System.ComponentModel.DataAnnotations.Schema; | |
| using System.Data.Entity.ModelConfiguration; | |
| using EntityFrameworkExamples.Models; | |
| namespace EntityFrameworkExamples.Mappings | |
| { | |
| class UserMapping : EntityTypeConfiguration<User> | |
| { | |
| public UserMapping() | |
| { | |
| ToTable("Users"); | |
| HasKey(m => m.Id); | |
| Property(m => m.Id).HasColumnName("ID").HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity); | |
| Property(m => m.Username).HasColumnName("Username").IsRequired(); | |
| Property(m => m.Password).HasColumnName("Password").IsRequired(); | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment