【发布时间】:2023-03-18 15:20:02
【问题描述】:
我将 web.config 中的连接字符串更改为使用 sqlexpress 而不仅仅是 localdb。我的应用程序仍然在 localdb 而不是 sqlexpress 中创建数据库。我被难住了。
这是我的连接字符串
Data Source=.\SQLEXPRESS;Initial Catalog=Jemco;Integrated Security=True;
可能是我的 app.config 的问题吗?
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
<parameters>
<parameter value="v11.0" />
</parameters>
</defaultConnectionFactory>
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
</providers>
</entityFramework>
</configuration>
【问题讨论】:
-
实体框架代码优先?查看(或在此处发布)初始化 DataContext 的行。
-
是的,我首先使用实体框架代码。我使用工作单元和存储库来处理数据库,但与那里的连接无关。也许我不理解你的要求。