[英]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.