zoukankan      html  css  js  c++  java
  • 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>

  • 相关阅读:
    SSL评测
    EF+SQLSERVER控制并发下抢红包减余额(改进)
    关于游标嵌套时@@FETCH_STATUS的值
    windows下限制Redis端口只能由本机访问
    windows下配置Redis
    Node.js 使用gm处理图像
    Git 与其他系统
    git-svn 简易 操作指南
    git-svn — 让git和svn协同工作
    Git和SVN共存的方法
  • 原文地址:https://www.cnblogs.com/love-summer/p/3610498.html
Copyright © 2011-2022 走看看