Skip to content

Instantly share code, notes, and snippets.

@mrstebo
Created June 2, 2020 12:18
Show Gist options
  • Select an option

  • Save mrstebo/e656ee5fa4ca0089d51dd9f9dea9ad6f to your computer and use it in GitHub Desktop.

Select an option

Save mrstebo/e656ee5fa4ca0089d51dd9f9dea9ad6f to your computer and use it in GitHub Desktop.
entity-framework-model-mapping-2
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