如何更改app.config或Migration Configuration.cs文件,以便Entity Framework使用本地SDF文件而不是本地SQL Server实例?我使用的是EF 6.1。
由于
<?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.SqlConnectionFactory, EntityFramework" />
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
</providers>
</entityFramework>
</configuration>
答案 0 :(得分:1)
您应该只能在数据库的连接字符串中指定ProviderName。
<connectionStrings>
<add name="DataModelContext"
providerName="System.Data.SqlServerCe.4.0"
connectionString="Data Source=location\cfdb.sdf"/>