I was using EF6's fluent mapping like this:
public SomeClass
{
public int SomeID { get; set; }
}
public SomeClassMap : EntityTypeConfiguration<SomeClass>
{
public SomeClassMap()
{
ToTable("SomeTable");
HasKey(c => c.SomeID);
}
}
And building the configuration from the assembly of the first requested type (model):
public class MyContext : DbContext
{
private Assembly _assembly;
public MyContext(string connectionName, Type type)
{
//checks
Database.Connection.ConnectionString = ConfigurationManager.ConnectionStrings[connectionName].ConnectionString;
_assembly = Assembly.GetAssembly(type);
}
public override void OnModelCreating(DbModelBuilder modelBuilder)
{
//conventions
//Not the ideal solution, still looking for something better
modelBuilder.Configurations.AddFromAssembly(_assembly);
}
}
Now I want to make a generic Data project, independent of the models, so I'd like to map via annotations and simply call the generic methods in my Data project.
I've mapped the class:
[Table("SomeTable")]
public SomeClass
{
[Key]
public int SomeID { get; set; }
}
Now how do I pass this to the Data project so it can build the model configuration?
Edit This might be relevant, since my Data project is generic, I don't have the DbSet<Entity> variables in it, instead I'm calling the context.Set<Entity> and using the functions from there.