Click here to Skip to main content
15,892,746 members
Articles / Desktop Programming / WPF

Using the Microsoft Desktop Stack – Part 3: Using Entity Framework 4 in an MVVM Application

Rate me:
Please Sign up or sign in to vote.
4.73/5 (21 votes)
17 Apr 2011CPOL25 min read 73.6K   4.9K   56  
This article, shows how to integrate Entity Framework 4 into a WPF application using the MVVM pattern.
<?xml version="1.0"?>
<configuration>
  
  <!-- Specify Configuration Sections -->
  <configSections>
    <!-- Create Log4Net Section -->
    <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net"/>
  </configSections>

  <system.data>
    <DbProviderFactories>
      <remove invariant="System.Data.SqlServerCe.4.0"/>
      <add name="Microsoft SQL Server Compact Data Provider 4.0" invariant="System.Data.SqlServerCe.4.0" description=".NET Framework Data Provider for Microsoft SQL Server Compact" type="System.Data.SqlServerCe.SqlCeProviderFactory, System.Data.SqlServerCe, Version=4.0.0.1, Culture=neutral, PublicKeyToken=89845dcd8080cc91"/>
    </DbProviderFactories>
  </system.data>

  <!-- Configure Log4Net -->
  <log4net>

    <!-- Log4Net Appenders -->
    <appender name="FileAppender" type="log4net.Appender.RollingFileAppender">

      <!-- Specify log file -->
      <file type="log4net.Util.PatternString">

        <!-- Use converter to get special folder -->
        <converter>
          <name value="folder"/>
          <type value="MsDesktopStackDemo.Utility.SpecialFolderPatternConverter,MsDesktopStackDemo"/>
        </converter>

        <!-- Use converter to specify log file -->
        <conversionPattern value="%folder{CommonApplicationData}\Foresight Systems\MS Desktop Stac kDemo\MS Desktop Stack Demo Log.txt"/>
      </file>

      <appendToFile value="true"/>
      <rollingStyle value="Once"/>
      <maximumFileSize value="100KB"/>
      <staticLogFileName value="true"/>
      <layout type="log4net.Layout.PatternLayout">
        <conversionPattern value="%logger [%level]- %message%newline"/>
      </layout>
    </appender>

    <!-- Log4Net Settings -->
    <root>
      <level value="ALL"/>
      <appender-ref ref="FileAppender"/>
    </root>

  </log4net>

<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup></configuration>
<!-- <add name="BooksContainer" connectionString="metadata=res://*/Model.Books.csdl|res://*/Model.Books.ssdl|res://*/Model.Books.msl;provider=System.Data.SqlServerCe.3.5;provider connection string=&quot;Data Source=D:\Users\dcveeneman\Desktop\MyDatabase#1.sdf&quot;" providerName="System.Data.EntityClient" /> -->

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior) Foresight Systems
United States United States
David Veeneman is a financial planner and software developer. He is the author of "The Fortune in Your Future" (McGraw-Hill 1998). His company, Foresight Systems, develops planning and financial software.

Comments and Discussions