• Tow types of EF's default connection


    When you create a new project that makes use of Entity Framework 5, you'll notice how it uses LocalDb by default now. But let's assume you have a fully working instance of Sql Server that you wish to work against instead of LocalDb. How do you tell EF to use it? Simple, modify your application's config file. If you are running a web service or a website, your config file is web.config. If you are running a console application or a windows application, look for app.config.

    LocalDb

      <entityFramework>

        <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">

          <parameters>

            <parameter value="v11.0" />

          </parameters>

        </defaultConnectionFactory>

      </entityFramework>

    Now, replace that portion of the configuration to make use of Sql Server instead of LocalDb.

    Sql Server

      <entityFramework>

        <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework">

          <parameters>

            <parameter value="Data Source=.; Integrated Security=True; MultipleActiveResultSets=True" />

          </parameters>

        </defaultConnectionFactory>

      </entityFramework>

  • 相关阅读:
    洛谷-P5709 【深基2.习6】Apples Prologue
    右键添加功能
    配置Java环境变量遇到的坑
    mysql安装
    页面置换算法
    程序员画图软件
    Java中传值和传引用
    计算机网络之链路层
    Python开发【第十五篇】模块的导入
    Python开发【第十四篇】装饰器
  • 原文地址:https://www.cnblogs.com/love-summer/p/3610498.html
Copyright © 2020-2023  润新知