Click here to Skip to main content
15,881,757 members
Articles / Programming Languages / C#

Mixed Style Development in Entity Framework

Rate me:
Please Sign up or sign in to vote.
4.75/5 (4 votes)
4 Nov 2011CPOL13 min read 38.5K   950   37  
There are three development styles in Entity Framework: Database-First, Model-First, and Code-First. In this article, I will show a mixed development style with Entity Framwork.
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <configSections>
    <section name="unity" type="Microsoft.Practices.Unity.Configuration.UnityConfigurationSection, Microsoft.Practices.Unity.Configuration" />
  </configSections>

  <unity xmlns="http://schemas.microsoft.com/practices/2010/unity">
    <alias alias="IContext" type="Demo.Models.DataInterfaces.IContext, Demo.Models" />
    <alias alias="Context" type="Demo.Data.Context, Demo.Data" />
    <alias alias="IRepositoryFactory" type="Demo.Models.DataInterfaces.IRepositoryFactory, Demo.Models" />
    <alias alias="RepositoryFactory" type="Demo.Data.RepositoryFactory, Demo.Data" />
    <container>
      <register type="IContext" mapTo="Context">
        <lifetime type="PerThreadLifetimeManager" />
      </register>
      <register type="IRepositoryFactory" mapTo="RepositoryFactory">
        <constructor>
          <param name="context" />
        </constructor>
      </register>
    </container>
  </unity>

  <connectionStrings>
    <add name="EntityFrameworkMixedStyleDevelopmentEntities" connectionString="metadata=res://*/DataModel.csdl|res://*/DataModel.ssdl|res://*/DataModel.msl;provider=System.Data.SqlClient;provider connection string=&quot;Data Source=LAPTOP;Initial Catalog=EntityFrameworkMixedStyleDevelopment;Integrated Security=True;MultipleActiveResultSets=True&quot;" providerName="System.Data.EntityClient" />
  </connectionStrings>

</configuration>

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)
United States United States
Senior Software Developer from New Jersey, USA

Have 15+ years experience on enterprise application development with various technologies.

Comments and Discussions