Entity Framework defaultconnectionfactory

I recently created a new web project using Entity Framework 4.3. I am using the first database project.

Entity Framework added this section to my web.config which gives some informational error messages. I read somewhere that this code refers to the first design of the code - I need it - am I just deleting it?

<entityFramework>
  <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlCeConnectionFactory, EntityFramework">
    <parameters>
      <parameter value="System.Data.SqlServerCe.4.0" />
    </parameters>
  </defaultConnectionFactory>
</entityFramework>

      

Thank.

+3


source to share


3 answers


I'm not 100% sure if this matters if you're not using CodeFirst (try uninstalling it and see if it works fine). However, if you are using CodeFirst and are using SQLCE 4.0 as your main database, you need to save it. See docs :



If you haven't established a default factory connection, Code First uses the SqlConnectionFactory pointing to. \ SQLEXPRESS. SqlConnectionFactory also has a constructor that allows you to override parts of the connection string. If you want to use a SQL Server instance other than. \ SQLEXPRESS, you can use this constructor to install the server.

+2


source


This can be very relevant (attention mine):

In the config section, you can specify a default factory connection that Code First should use to find the database to use for the context. The default factory connection is only used when no connection string for context has been added to the config file .



See Entity Framework Configuration File Settings on MSDN.

+18


source


You are getting these warning messages because the section element definition for entityFramework is missing from Web.config

. It looks something like this: (note: below for EF5.0)

<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=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />

      

0


source







All Articles