zoukankan      html  css  js  c++  java
  • MVC4中使用EntityFramework

    首先,MVC4不支持EntityFramwok 6版本,如果安装了EntityFramwok 6,则vs不会自动引用dll和修改web.config配置。
    先删除旧的版本,执行指令:
    Uninstall-Package EntityFramework.zh-Hans
    Uninstall-Package EntityFramework  [-force]
    如:

     
    然后,
    通过NuGet安装EntityFramwok,可以指定要使用的版本,如(MVCEF1为项目名称):
    Install-Package EntityFramework -ProjectName MVCEF1 -Version 5.0

    执行成功后,web.config配置如下:
    <configSections>
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=4.4.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
    <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
    </configSections>
    ......
    <entityFramework>
    <contexts>
      <context type="MVCEF1.DAL.AccountContext,MVCEF1">
        <databaseInitializer type="MVCEF1.DAL.AccountInitializer,MVCEF1"></databaseInitializer>
      </context>
    </contexts>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
    </entityFramework>


    参考:
    http://www.mamicode.com/info-detail-128217.html

  • 相关阅读:
    大四实习几个课题
    Keil 4 与Proteus 7.8联调
    局域网共享
    win 8.1 网卡
    路由器无线桥接 router wireless bridge
    系统对话框alert-prompt-confirm
    处理浏览器兼容性
    pageX--clientX--scrollLeft-clientLeft-offsetWidth
    处理注册事件的兼容性问题
    处理innerText的兼容性问题
  • 原文地址:https://www.cnblogs.com/zhaow/p/9754045.html
Copyright © 2011-2022 走看看