Created
June 2, 2020 12:18
-
-
Save mrstebo/e656ee5fa4ca0089d51dd9f9dea9ad6f to your computer and use it in GitHub Desktop.
entity-framework-model-mapping-2
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.Data.Entity; | |
| using EntityFrameworkExamples.Models; | |
| namespace EntityFrameworkExamples.Data | |
| { | |
| public class ApplicationContext : DbContext | |
| { | |
| public virtual IDbSet<User> Users { get; set; } | |
| public ApplicationContext() | |
| : base("DefaultConnection") | |
| { | |
| } | |
| protected override void OnModelCreating(DbModelBuilder modelBuilder) | |
| { | |
| // Get mappings from this assembly | |
| modelBuilder.Configurations.AddFromAssembly(GetType().Assembly); | |
| base.OnModelCreating(modelBuilder); | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment