MVC实现EF模型随意切换(四)学习

来源:互联网 发布:超级经典算法大集合 编辑:程序博客网 时间:2024/06/01 21:35

DAL层

 public class BaseDal<T> where T : class , new()        private DbContext db = EFDbcontextFactory.GetcurrentDbcontext();


创建类

using System;using System.Collections.Generic;using System.Data.Entity;using System.Linq;using System.Text;using Dulei.Model;namespace Dulei.DAL{     public class EFDbcontextFactory    {         public static DbContext GetcurrentDbcontext()         {             //可以直接对Model模型进行切换。只要更改DataModelContainer()             return new DataModelContainer();         }    }}



0 0