我刚刚使用Microsoft.AspNet.Identity.EntityFramework 2.2.1创建了一个具有正常运行身份模型的项目。一切正常,期望它使用Insert语句。有没有办法我可以覆盖一些东西让它调用我自己的procs或使其使用存储过程?
答案 0 :(得分:1)
使用Fluent API,您可以指定为您的用户实体使用存储过程。
public class ApplicationDbContext : IdentityDbContext<ApplicationUser>
{
//...
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
//Since it extends IdentityDbContext<T>
base.OnModelCreating(modelBuilder);
modelBuilder
.Entity<ApplicationUser>()
.MapToStoredProcedures(s =>
{
s.Insert(i => i.HasName("insert_user"));
});
}
}