2

How do I change my app.config or Migration Configuration.cs file so Entity Framework uses a local SDF file instead of a local SQL Server instance ? I am using EF 6.1.

Thanks

<?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>

1 Answer 1

1

You should just be able to specify the ProviderName in the connection string to your database.

<connectionStrings>
<add name="DataModelContext"
     providerName="System.Data.SqlServerCe.4.0"
     connectionString="Data Source=location\cfdb.sdf"/>

Sign up to request clarification or add additional context in comments.

2 Comments

And install the EntityFramework.SqlServerCompact nuget package
Yep, I shouldn't have assumed that.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.