EntityFramework 6 Tips
程序员文章站
2022-07-09 19:22:20
When working with Web applications, use a context instance per request. Install-Package EntityFramework -Version using System.Data.Entity; public clas ......
when working with web applications, use a context instance per request.
install-package entityframework -version
using system.data.entity; public class category{} public class product{} public class productcontext : dbcontext { public dbset<category> categories { get; set; } public dbset<product> products { get; set; } } public void useproducts() { using (var context = new productcontext()) { // perform data access using the context } }