화재 발생하고 싶습니다. OnModelCreating every new DataContext(new Entity())
... 하지만 테이블 연결을 만들면 작동합니다. 때, 나는 오류를 가지고 있기 때문에, 그래서 다시 나던 작업을 OnModelCreating,화재를 강제하는 방법 OnModel 모든 DataContext를 초기화합니다.
public class DataContext : DbContext
{
private BaseEntity _entity;
public DataContext(BaseEntity entity)
{
Database.Connection.ConnectionString = Parameters.ConnectionString;
_entity = entity;
}
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
_entity.Map(modelBuilder); // this is dynamic fluent api here
}
}
내 프로젝트에는 사용할 수없는 제네릭을 사용할 수 없습니다. Unit Of Work는 내 프로젝트에서이를 차단합니다. 이 사용법은 지금 당장 나를 위해 더 유용합니다. –
db 작업이있을 때 모든 엔티티에 대해 DataContext를 이미 작성하고 있습니다. 그러나 datacontext를 처음 생성 한 후에는 onmodelconfiguring이 더 이상 작동하지 않습니다. 하지만 저는 유창한 API를 바꿔야 만합니다. 그래서 나는 onmodelcreating을 발사해야합니다. –
런타임시 DbModelBuilder에 유창한 API를 실행할 수 있습니까? –