0

I googled/searched for an answer here in SO, but didn't find anything, specially specific for model-first approach.
I am just starting with creation of a new model for my new database and want to organize the entities for tables that logically belong to different scopes by having multiple schemas. I am using .NET-4.5

thanks in advance.

tiwarib
  • 441
  • 6
  • 17

1 Answers1

0

imagine that you have these two classes (Models):

public class Order
    {   
    }

 public class Book
    {

    }

now in entity framework code first, you can implement the table in schema like this:

public class ContextClass : DbContext
        {
            protected override void OnModelCreating(DbModelBuilder modelBuilder)
            {
                modelBuilder.Entity<Order>().ToTable("Order", schemaName: "Orders");
                modelBuilder.Entity<Book>().ToTable("Book", schemaName: "Books");
            }
            public DbSet<Book> Customers { get; set; }
            public DbSet<Order> Orders { get; set; }
        }
Ehsan
  • 816
  • 9
  • 27