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>

Tow types of EF's default connection的更多相关文章

  1. EF 数据库连接约定(Connection String Conventions in Code First)

    一个典型的EF应用大多数情况下是一个DbContext的派生类(derived class)来控制,通常可以使用该派生类调用DbContext的构造函数,来控制以下的东西: (1).上下文如何连接到数 ...

  2. python连接redis文档001

    Installation redis-py requires a running Redis server. See Redis’s quickstart for installation instr ...

  3. Config File Settings Of EF——实体框架的配置文件设置

    我亦MSDN 原文地址 http://msdn.microsoft.com/en-us/data/jj556606 Entity Framework allows a number of settin ...

  4. 自定义 ASP.NET Identity Data Model with EF

    One of the first issues you will likely encounter when getting started with ASP.NET Identity centers ...

  5. EF 约定介绍

    当前环境为EF Code First开发模式中 一.EF默认约定 1.常用约定 (1).当没有显示指定实体主键的时候,EF会默认将长得最像Id的属性(且类型为GUID)设为主键 (2).设计实体时,当 ...

  6. EntityFramework:EF Migrations Command Reference

    Entity Framework Migrations are handled from the package manager console in Visual Studio. The usage ...

  7. Mongoose Connection best practice

    There is often quite a lot of confusion about how best to set up a database connection with Mongoose ...

  8. SQL Server Connection Pooling (ADO.NET)

    SQL Server Connection Pooling (ADO.NET) Connecting to a database server typically consists of severa ...

  9. [转]Oracle connection strings

    本文转自:http://www.connectionstrings.com/oracle/ Standard Data Source=MyOracleDB;Integrated Security=ye ...

随机推荐

  1. 哈工大LTP语言分析:分词、词性标注、句法分析等

    1. LTP介绍和安装 LTP语言云官网  在线演示 | 语言云(语言技术平台云 LTP-Cloud) 安装LTP的python接口包 $ sudo pip install pyltp 模型文件下载 ...

  2. 【剑指offer-25】合并两个单调递增的链表,C++实现(链表)

    原创博客,转载请注明出处! 1.题目 输入两个单调递增的链表,输出两个链表合成后的链表(单调不减). 2.思路(递归) # 鲁棒性: 如果链表1是空链表,则直接输出链表2. 如果链表2是空链表,则直接 ...

  3. 开源中文检索引擎Coreseek简单使用

    Coreseek结合MySQL使用简单示例,如下所示: echo 北京 | iconv -f gbk -t utf-8 | search -c D:\web\coreseek\etc\csft_mys ...

  4. BZOJ4152 AMPPZ2014 The Captain 【最短路】【贪心】*

    BZOJ4152 AMPPZ2014 The Captain Description 给定平面上的n个点,定义(x1,y1)到(x2,y2)的费用为min(|x1-x2|,|y1-y2|),求从1号点 ...

  5. 【2018.06.26NOIP模拟】T1纪念碑square 【线段树】*

    [2018.06.26NOIP模拟]T1纪念碑square 题目描述 2034年,纪念中学决定修建校庆100周年纪念碑,作为杰出校友的你被找了过来,帮校方确定纪念碑的选址. 纪念中学的土地可以看作是一 ...

  6. pip 在windows下的更新升级

    1. pip 在 PyCharm 无法自动更新 2.   https://pip.pypa.io/en/latest/installing.html 官方网页要求在 cmd中输入以下命令进行 pip的 ...

  7. ssh连接至Ubuntu服务器时,提示以下错误:REMOTE HOST IDENTIFICATION HAS CHANGED!

    今天在使用Ubuntu搭建自己的git仓库的时候,搭建完成后clone时出现以下错误 经过搜索问题出现原因的描述如下:第一次使用SSH连接时,会生成一个认证,储存在客户端的known_hosts中. ...

  8. sublime python运行插件

    Tools->New plugin 粘贴下面代码,在插件目录新建文件夹,保存 import sublime, sublime_plugin import os class ExampleComm ...

  9. WPF中Grid实现网格,表格样式通用类(转)

    /// <summary> /// 给Grid添加边框线 /// </summary> /// <param name="grid"></ ...

  10. FastAdmin 前端页面传参笔记

    FastAdmin 前端页面传参笔记 看到 QQ 群里的小伙伴询问如何传参,然后在社区里找到一笔记帖子 1 还要参考在线文档控制器部分2. 引用 Karson 的回复: 如果我们需要自己在控制器中透传 ...