Here is what I have currently in MyContext class
public class MyContext:DbContext
{
public DbSet<Country> Countries { get; set; }
public DbSet<State> States { get; set; }
}
What I want is to place all these DbSet
properties into a separate file and just have one statement on MyContext
class to add all DbSet
from that separate file.
Use a partial class and define the DbSet<T>
properties there.
MyContext.cs
public partial class MyContext:DbContext
{
}
MyContextProperties.cs
public partial class MyContext:DbContext
{
public DbSet<Country> Countries { get; set; }
public DbSet<State> States { get; set; }
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.