Creating Entity Data ADO.NET Data Model Files, Where to Start?

Our product is partly built using Delphi and partly .NET and in our current migration state to .NET we have a data dictionary in a Delphi component, so this is a wizard.

From this, we create .NET source code using templates, support a simple query, and also make Linq2Sql as our product requires SQL Server.

However, I would like to switch to the new Entity model in .NET instead of Linq2Sql, but I don't know how much work that would be. All tutorials or examples I find revolve around modeling a data model in a designer or getting it from a database, and don't work for our needs.

In Linq2Sql, we annotated our query classes with TableMappingAttribute and ColumnMappingAttribute and then generated a descendant of DataContext, it all works very well.

Is there an equally easy way to use Entity model code instead? Or do I need to create all these XML files and run tools to create resources, etc.?

Has anyone been in the same situation and can shed some light on this?

+2


source to share


1 answer


Sorry for you, I think you need XML files.

There are actually 3 files that make up the EDM. (although in visual studio they are all merged into 1 EDMX file)

  • ssdl - storage (Describes the database)
  • csdl - conceptual (describes data objects)
  • msl - mapping (Describes mapping between storage and conceptual)

From EDM files, the EDM Generator can be used to generate all three from the database connection as well as the msl and csdl from the ssdl, or it can generate the actual data objects from the csdl.



Unfortunately, this is not where XML ends up. At runtime, it is still necessary for the entity framework to do the translation from objects to storage, etc. Link to 3 EDM files should be provided in the Entity framework connection string . (More information on building EF connection strings )

You could probably create ways to code your data objects (or automatically tag existing ones with various required attributes and optional methods). For example, Linq has attributes such as EdmEntityTypeAttribute and EdmScalarPropertyAttribute that are put into classes and properties, but without 3 EDM files, the entity framework won't know what to do with your data objects. The generator also adds other things to the data object classes such as property changed events and EntityObject inheritance. I'm not sure what of the additional stuff is required for the entity framework to work properly and what is developer-only. I would suggest that property change events are required by the data context to track changes.

Here's an article on EDM tools and some code to generate / split EDMX files into their ssdl / csdl / msl files. / P>

+3


source







All Articles