Click here to Skip to main content
Click here to Skip to main content

How to do a polymorphic association like Rails using Entity Framework

By , 7 Jan 2013
 
Polymorphic_Sample-noexe.zip
ConsoleApplication1.v11.suo
ConsoleApplication1
bin
Debug
ClassDiagram1.cd
Migrations
obj
Debug
ConsoleApplication1.Migrations.test.resources
Properties
packages
EntityFramework.5.0.0
Content
App.config.transform
Web.config.transform
EntityFramework.5.0.0.nupkg
EntityFramework.5.0.0.nuspec
lib
net40
net45
tools
EntityFramework.PS3.psd1
EntityFramework.psd1
EntityFramework.psm1
init.ps1
install.ps1
Polymorphic_Sample.zip
ConsoleApplication1.v11.suo
ConsoleApplication1.exe
ConsoleApplication1.pdb
ConsoleApplication1.vshost.exe
EntityFramework.dll
Release
ClassDiagram1.cd
ConsoleApplication1.csproj.GenerateResource.Cache
ConsoleApplication1.csprojResolveAssemblyReference.cache
ConsoleApplication1.exe
ConsoleApplication1.Migrations.test.resources
ConsoleApplication1.pdb
DesignTimeResolveAssemblyReferencesInput.cache
TempPE
App.config.transform
Web.config.transform
EntityFramework.5.0.0.nupkg
EntityFramework.5.0.0.nuspec
EntityFramework.dll
EntityFramework.dll
EntityFramework.PowerShell.dll
EntityFramework.PowerShell.Utility.dll
EntityFramework.PS3.psd1
EntityFramework.psd1
EntityFramework.psm1
init.ps1
install.ps1
migrate.exe
<?xml version="1.0" encoding="utf-8"?>
<root>
  <!-- 
    Microsoft ResX Schema 
    
    Version 2.0
    
    The primary goals of this format is to allow a simple XML format 
    that is mostly human readable. The generation and parsing of the 
    various data types are done through the TypeConverter classes 
    associated with the data types.
    
    Example:
    
    ... ado.net/XML headers & schema ...
    <resheader name="resmimetype">text/microsoft-resx</resheader>
    <resheader name="version">2.0</resheader>
    <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
    <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
    <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
    <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
    <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
        <value>[base64 mime encoded serialized .NET Framework object]</value>
    </data>
    <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
        <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
        <comment>This is a comment</comment>
    </data>
                
    There are any number of "resheader" rows that contain simple 
    name/value pairs.
    
    Each data row contains a name, and value. The row also contains a 
    type or mimetype. Type corresponds to a .NET class that support 
    text/value conversion through the TypeConverter architecture. 
    Classes that don't support this are serialized and stored with the 
    mimetype set.
    
    The mimetype is used for serialized objects, and tells the 
    ResXResourceReader how to depersist the object. This is currently not 
    extensible. For a given mimetype the value must be set accordingly:
    
    Note - application/x-microsoft.net.object.binary.base64 is the format 
    that the ResXResourceWriter will generate, however the reader can 
    read any of the formats listed below.
    
    mimetype: application/x-microsoft.net.object.binary.base64
    value   : The object must be serialized with 
            : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
            : and then encoded with base64 encoding.
    
    mimetype: application/x-microsoft.net.object.soap.base64
    value   : The object must be serialized with 
            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
            : and then encoded with base64 encoding.

    mimetype: application/x-microsoft.net.object.bytearray.base64
    value   : The object must be serialized into a byte array 
            : using a System.ComponentModel.TypeConverter
            : and then encoded with base64 encoding.
    -->
  <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
    <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
    <xsd:element name="root" msdata:IsDataSet="true">
      <xsd:complexType>
        <xsd:choice maxOccurs="unbounded">
          <xsd:element name="metadata">
            <xsd:complexType>
              <xsd:sequence>
                <xsd:element name="value" type="xsd:string" minOccurs="0" />
              </xsd:sequence>
              <xsd:attribute name="name" use="required" type="xsd:string" />
              <xsd:attribute name="type" type="xsd:string" />
              <xsd:attribute name="mimetype" type="xsd:string" />
              <xsd:attribute ref="xml:space" />
            </xsd:complexType>
          </xsd:element>
          <xsd:element name="assembly">
            <xsd:complexType>
              <xsd:attribute name="alias" type="xsd:string" />
              <xsd:attribute name="name" type="xsd:string" />
            </xsd:complexType>
          </xsd:element>
          <xsd:element name="data">
            <xsd:complexType>
              <xsd:sequence>
                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
                <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
              </xsd:sequence>
              <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
              <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
              <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
              <xsd:attribute ref="xml:space" />
            </xsd:complexType>
          </xsd:element>
          <xsd:element name="resheader">
            <xsd:complexType>
              <xsd:sequence>
                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
              </xsd:sequence>
              <xsd:attribute name="name" type="xsd:string" use="required" />
            </xsd:complexType>
          </xsd:element>
        </xsd:choice>
      </xsd:complexType>
    </xsd:element>
  </xsd:schema>
  <resheader name="resmimetype">
    <value>text/microsoft-resx</value>
  </resheader>
  <resheader name="version">
    <value>2.0</value>
  </resheader>
  <resheader name="reader">
    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
  </resheader>
  <resheader name="writer">
    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
  </resheader>
  <data name="Target" xml:space="preserve">
    <value>H4sIAAAAAAAEAN1aS2/cNhC+F+h/EHRKCmRlJzmkwW4Cx4/CaG2n3iRXg5Zm10QpUhUpw/vbeuhP6l/oUG+R1Eq761dyWWjF4bw1/DSj//75d/rxLmbeLaSSCj7z9yd7vgc8FBHly5mfqcWrd/7HDz//ND2O4jvvW0X3Rt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OM6VIZIKQg8T3U/ZZGGoDMV1JBPNEEk/nf7JBRTOCG4IxwutC5L/4CBJ6Ikd4Zfa4telCBlBF7ho0oqi0f7D9YTYvxPSh+S9LwhqQvYnL38p7egp+uiXMP7trYyi3zYn2BcdI7SIed05HT8tKGOVOJH8th08aT+ar/WMnyOI/OqObVQzyKLrDzw/vWamrdg2cHGlVOtOFoVYzqUe1bWOeCHwEDBd5BWLRbDokMSWR7QqOAIR3yppFDjeHulh5QwQJSXUgJ03hOpQgYLHT5OaU8pAlhpvU26BmTeNqumqW5cgQJcF3aHVaOETcA9Gr2hp+H/NDbCBxKJBc87AZxqCX5I6bPM82cp0ua8vy40oFoeF3pydFVk1Diqud43boy9XfPa0ltRs3NLqO9ycTm9exrS38/Z7SsR0iN/PgbTAwnMniAtCjltNlUt36ElOjrJj1dQrgnTXbzv6er3Hrb7Zk3FW/sMz+6FhjWAkg5Jy19k6i1g6ge7u5xUK+IXvWb1XWCRpnT1DZLULPkktKsDkioHhSLf7Xg4l6tbTzRqwdxA4O9ns6as3i4JgJjRnqt+FmNwPEDvXFmV4PDIbPdjTsTmxnjqac3dmOk4HDEbmjjnnLDfN66I5bdHbXRuelw0vbn7j05qFsu2sOOB5mB2z1fPLVa3y/iWSnpsmGhv2bkEHbOq5rmlC9EdWQaGlUkxlv+GSgS4WGmM2BBQoXLIUiZf73yjbAMSY7ja4hO+UWmkkyhyRBfs87nWvr4XSc/H/R3dZ5eJPnHW/dhAqpJ0QS44J8yyqJa7xNHP62HhT7Xy16njqXSPc/lquZ0LvhIRqX7ajjyBeKEITN5wefkFvp1G/Zh12PTI0qWKYllyaPZj38x/aL47sP/u8ERjYErAAA=</value>
  </data>
</root>

By viewing downloads associated with this article you agree to the Terms of use 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)

About the Author

fernando albernaz
Architect BNP Paribas
Brazil Brazil
Member
No Biography provided

Permalink | Advertise | Privacy | Mobile
Web04 | 2.6.130516.1 | Last Updated 7 Jan 2013
Article Copyright 2013 by fernando albernaz
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid