首先使用实体框架代码创建存储过程? [英] Create Stored Procedures using Entity Framework Code First?
问题描述
请帮助我有人,使用Entity Framework Code First策略创建存储过程的最佳方法是什么?
请帮助我,谢谢。
使用StringBuilder可以使用现有的EF方法
public override void Up()
{
CreateStoredProcedure b $ bMyStoredProcedure,
p => new
{
id = p.Int()
},
@SELECT some-data FROM my-表WHERE id = @id
);
}
public override void Down()
{
DropStoredProcedure(MyStoredProcedure);
}
I am using Entity Framework Code First in my current project. A Database consists of many tables, many views, and many functions. I am able to create tables using Entity Framework Code First. But I am unable to find a way to create stored procedures using Entity Framework Code First. I know Database-First strategy will fulfill my requirement and everything works well, but I don’t want to use Database-First strategy into my existing project code.
Please help me someone, what are the best ways to create stored procedures using Entity Framework Code First strategy?
Please help me with it, Thanks.
Instead of using StringBuilder you can use existing EF methods
public override void Up()
{
CreateStoredProcedure(
"MyStoredProcedure",
p => new
{
id = p.Int()
},
@"SELECT some-data FROM my-table WHERE id = @id"
);
}
public override void Down()
{
DropStoredProcedure("MyStoredProcedure");
}
这篇关于首先使用实体框架代码创建存储过程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!