The EF is (Entity Framework) unique to the DbContext startup thread for the database context, so that there is no dirty data to process the data, and you can use the factory to co-create DbContext
Dbsession Instance Code:
public class Dbsession:idbsession
{
Private DbContext Db
{
Get
{
Create thread the only ef,dbcontextfactory is the EF factory
return Dbcontextfactory.createunitycontext ();
}
}
dbcontextfactory Code : function to determine whether the data context exists is unique to the data context
DbContext DbContext = (DbContext) callcontext.getdata ("DbContext");
if (dbcontext==null)
{
DbConText = new Oaentities ();//oaentities () is the data context Model1. Context.cs in the
//. SetData ("DbConText", dbConText); store data
Callcontext.setdata ("DbConText", DbConText);
}
return dbConText;
How to implement multi-table operations to save data one time, in order to avoid using the data link pool multiple link database
Unified extraction in Dbsession painting
Db.savechanges () can be solved in the installation and interface
So the EF thread is the only one that's docked to the Dbsession interface.
EF thread unique docking with Dbsession interface