Visual Studio 2013 EF5 Object Data Model edmx uses the inherited object dbcontext generated by the T4 template. The familiar objectcontext object is missing. Of course, not every programmer needs the objectcontext object, there are two solutions:
Method 1. open model. Context. CS and add
Public oraclemodelentities (objectcontext, bool dbcontextownsobjectcontext)
: Base (objectcontext, dbcontextownsobjectcontext)
{}
As follows:
using System; using System.Data.Entity; using System.Data.Entity.Infrastructure; using System.Data.Objects; public partial class OracleModelEntities : DbContext { public OracleModelEntities() : base("name=OracleModelEntities") { } public ModelEntities(ObjectContext objectContext, bool dbContextOwnsObjectContext) :base(objectContext, dbContextOwnsObjectContext) { } protected override void OnModelCreating(DbModelBuilder modelBuilder) { throw new UnintentionalCodeFirstException(); }
The usage is as follows:
public OracleModelEntities db = new OracleModelEntities(new ObjectContext(EntityConnectionHelper.OracleEntityConnection("OracleModel")), true);
Method 2. open the edmx file in the design view, change "code generation policy" to "default" in the property panel, and then change ". delete the TT file, right-click edmx, and select "Run custom tool". The generated code parent class is objectcontext.
Visual Studio 2013 EF5 Object Data Model edmx uses the objectcontext object after the T4 template is generated