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. 判断Integer值相等最好不用==最好使用equals

    Integer c = 3;Integer d = 3;Integer e = 321;Integer f = 321;System.out.println(c == d);System.out.pr ...

  2. 学习三部曲:WHAT、HOW、WHY

    一个人学习的过程要经历以下三步,才可以说得上"学会"两字: 第一步:WHAT 所谓的"WHAT",就是搞清楚某个东东是什么?有什么用?有什么语法?有什么功能特性 ...

  3. YXY-压测

    1.首先介绍一下组件Synchronizing Timer Number of Simulated users to Group by:集合点集合够N个用户开始并发 Timeout in millis ...

  4. Vue学习笔记 ——v-html

    v-html: 在网页中,后台传来的json数据中包含html标签,将该json数据绑定到Vue.js中对象中,对该对象进行for循环,发现数据中的html标签不能被解析,而是当作字符显示出来 解决: ...

  5. [转] 用深度学习(CNN RNN Attention)解决大规模文本分类问题 - 综述和实践

    转自知乎上看到的一篇很棒的文章:用深度学习(CNN RNN Attention)解决大规模文本分类问题 - 综述和实践 近来在同时做一个应用深度学习解决淘宝商品的类目预测问题的项目,恰好硕士毕业时论文 ...

  6. Aria2 - OS X 下载百度云资源神器

    官网介绍: (Aria2 is a light weight multi-protocol & multi-source command-line download utility. It s ...

  7. 打开U盘时出现“使用驱动器 X:中的光盘之前需要将其格式化。”字样

    今天打开U盘时出现如下情况,吓死宝宝了,格式化!!!里面还有好多数据嘞,幸好最终找到方法解决了这个问题. 解决方法: 1.下载DiskGenius软件 2.工具->搜索已丢失分区(重建分区):不 ...

  8. RBM

    1. 玻尔兹曼分布: $$p(E) \thicksim e^{-E/kT} $$ 2. RBM 两层:隐层和可视层, $\mathbf v$, $\mathbf h$ $$v_i \in \{0, 1 ...

  9. vim简单的文本编辑命令

    <blockquote>:e! enter</blockquote>消除所有这次编辑的,回到原来文件的样子.不过此文件还是打开状态.<blockquote>:q! ...

  10. Django博客开发实践,初学者开发经验

    python,Django初学者,开发简易博客,做了一下笔记,记录了开发的过程,功力浅薄,仅供初学者互相 交流,欢迎意见建议.具体链接:Django博客开发实践(一)--分析需求并创建项目 地址:ht ...