简体   繁体   English

实体框架代码第一个默认SQL Server实例?

[英]Entity Framework Code First Default SQL Server Instance?

If we do not specify EF Code First uses SQLEXPRESS instance in our machine to create the database from our POCO classes. 如果我们没有指定EF Code First在我们的机器中使用SQLEXPRESS实例来从我们的POCO类创建数据库。 Is there a way to change the default instance without giving a connection string(specifying with the databse)? 有没有办法在不提供连接字符串的情况下更改默认实例(使用数据库指定)? I mean when i run my application for the first time i want EF Code First to create the database in my "." 我的意思是当我第一次运行我的应用程序时,我希望EF Code First在我的“。”中创建数据库。 instance. 实例。

This will help you: http://blogs.msdn.com/b/adonet/archive/2012/01/12/ef-4-3-configuration-file-settings.aspx 这将对您有所帮助: http//blogs.msdn.com/b/adonet/archive/2012/01/12/ef-4-3-configuration-file-settings.aspx

In 4.3, you can use a constructor: 在4.3中,您可以使用构造函数:

If you don't set a default connection factory, Code First uses the SqlConnectionFactory, pointing to .\\SQLEXPRESS. 如果未设置默认连接工厂,则Code First将使用指向。\\ SQLEXPRESS的SqlConnectionFactory。 SqlConnectionFactory also has a constructor that allows you to override parts of the connection string. SqlConnectionFactory还有一个构造函数,允许您覆盖连接字符串的一部分。 If you want to use a SQL Server instance other than .\\SQLEXPRESS you can use this constructor to set the server. 如果要使用。\\ SQLEXPRESS以外的SQL Server实例,可以使用此构造函数来设置服务器。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用默认SQL实例时的实体框架代码优先超时 - Entity Framework Code First timeouts when using default SQL instance 外部SQL服务器上的实体框架代码优先 - Entity Framework Code First on external SQL server 实体框架代码第一个错误“找到指定的服务器/实例时出错” - Entity Framework Code First Error “Error Locating Server/Instance Specified” 如何使用实体框架生成与SQL Server兼容的数据库(代码优先) - How to generate a SQL Server compatible database with Entity Framework (code first) SQL Server数据库转换为实体框架代码优先 - Converter of SQL Server DB to Entity Framework Code First 实体框架代码优先和SQL Server 2012序列 - Entity Framework Code First and SQL Server 2012 Sequences 实体框架代码的SQL Server Compact 4.0连接字符串首先? - SQL Server Compact 4.0 connection string for Entity Framework code first? 实体框架代码首先在SQL Server Management Studio中没有数据库 - Entity Framework Code First no database in SQL Server Management Studio 实体框架代码优先迁移与SQL Server失败 - Entity Framework Code-First Migration Fails with SQL Server 在本地使用SQL Server CE和在生产实体框架代码上使用SQL Server 2008? - Use SQL Server CE Locally and SQL Server 2008 on Production Entity Framework Code First?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM