locked
Differences between Oracle and SQL Server generated Entity Data Models RRS feed

  • Question

  •  

    If I generate an Entity Data Model using the current Entity Data Model designer tools in Visual Studio that currently work for SQL Server, when Oracle releases their EDM Designer tools, will this ultimately create a different .Net-based Entity than the one for SQL Server? 

     

    If that is the case, how do I manage an Entity when I need to connect to two different back-end databases?  I thought that once this has been generated into a Data Model for .Net it should be independent of the underlying Data Provider?

     

    If this is not the case, do I have to use some type of Factory Method to selectively select an Entity Data Model based on the ADO.Net Connection string?

    Thanks.

     

    Monday, October 6, 2008 5:33 PM

Answers

  •  

    Classic ADO.NET uses a provider model, and the Entity Framework does as well (its actually an extension of the existing provider model).  This provides some abstraction for developers so that they don't have to be as concerned with the differences between vendors.  What Oracle (or some other 3rd party) will need to release is a new EF Provider that works with Oracle (as opposed to needing new tools).  The Entity Designer will work with other providers.

     

    An EDMX file encapsulates the 3 EF runtime models, the conceptual model (CSDL), the storage model (SSDL) and the mapping model.  The part of the EF which is aware of the underlying database is the SSDL model.  The SSDL model's type system is the underlying provider's type system (i.e., varchar in SQL Server, varchar2 in Oracle).

     

    If you look at the connection string that the designer builds (written to app.config or web.config) you will see that there is a metadata= section.  This is how you tell the EF runtime which model files to load when you instantiate a context.

     

    * http://msdn.microsoft.com/en-us/library/cc716756.aspx

     

    One way to do the switch you mention is to send the context a different entity connection string.  If the names of tables, etc., are the same between two vendor databases, then you could simply build a connection string which loaded different SSDL files.

     

    You could use VS and then Entity Designer to work with a built model against one of the databases, and then use Edmgen.exe to just build the second SSDL file.  To tell the designer to writes the files out to disk instead of embedding them as resources, you can click on the main canvas, right-click Properties and change the "Metadata Artifact Processing" value.

     

    Let me know if you need more help.

    Tuesday, October 21, 2008 9:57 PM