Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » EMF -> EF, anyone?
EMF -> EF, anyone? [message #430549] Wed, 27 May 2009 07:16 Go to next message
Miguel Garcia is currently offline Miguel GarciaFriend
Messages: 77
Registered: July 2009
Member
Today I was looking for a way to store Ecore models to be queried using
Microsoft LINQ (as to why, that's another story). Having found no ready-made
tool, I took a look at the API for retrieving (creating?) metadata for
consumption by the Entity Framework,
http://msdn.microsoft.com/en-us/library/bb399772.aspx

Looks close enough to the Ecore metamodel,
http://help.eclipse.org/help32/index.jsp?topic=/org.eclipse. emf.doc/references/javadoc/org/eclipse/emf/ecore/package-sum mary.html

And thus I was wondering whether someone had gone that path already. A
summary or utility for that would be most appreciated.


Miguel

--
Miguel Garcia miguel.garcia@tuhh.de
Institute for Software Systems (STS), E-16
Technische Universitaet Hamburg-Harburg
Harburger Schlossstr. 20, 21073 Hamburg Fax: (+49)40-42878-2515
http://www.sts.tu-harburg.de/people/mi.garcia
Re: EMF -> EF, anyone? [message #430591 is a reply to message #430549] Thu, 28 May 2009 13:03 Go to previous messageGo to next message
Krzysztof Kowalczyk is currently offline Krzysztof KowalczykFriend
Messages: 113
Registered: July 2009
Senior Member
Easiest solution IMO:
Use Ecore with generated XML Schema serialization not with XMI. Then
export and save Ecore model in "plain" XML and...

Then try what fit best:
- generate C# classes from XSD and use LINQ to objects - typed, works
well, but you need to generate C# classes for all XSDs

- LINQ to XSD - it is typed so you use "Library" and "Book", but I am
not sure how stable this project is
( http://www.microsoft.com/downloads/details.aspx?FamilyID=A45 F58CD-FCFC-439E-B735-8182775560AF&displaylang=en)

- LINQ to XML(XLINQ) - it is not typed, so you use "Element" and
"Attribute", so not that cool, but supported out of the box and mature



Some less attractive solutions:

2) Read Ecore XMI in C# model and use LINQ to objects

Read XMI somehow and then use LINQ to objects or even customize LINQ for
used classes.
Have you checked EMF4NET?

"XML and XMI serialization
Next big milestone. The reflective EObject API is working and a simple
XMI serialization use case is implemented (EClass with attributes can
be serialized)."

It would be good for the community to have EMF4NET XMI (de)serialization
and LINQ for EMF4NET :)

3) Look for, or create LINQ to XMI

One comment below
>
> Today I was looking for a way to store Ecore models to be queried using
> Microsoft LINQ (as to why, that's another story). Having found no
> ready-made tool, I took a look at the API for retrieving (creating?)
> metadata for consumption by the Entity Framework,
> http://msdn.microsoft.com/en-us/library/bb399772.aspx

AFAIK with Entity Framework you would need new C# Class model for each
Ecore metamodel that you want to read. Hm, it is possible to use Teneo
and Hibernate, or CDO to generate database schema. Then store the EMF
model there. To read it you can then:
- use LINQ to SQL
- use Entity Framework to generate C# entities from generated database
schema and LINQ for Entities

but this is quite complicated.

Regards,
Krzysztof Kowalczyk
Re: EMF -> EF, anyone? [message #430599 is a reply to message #430591] Fri, 29 May 2009 08:21 Go to previous messageGo to next message
Miguel Garcia is currently offline Miguel GarciaFriend
Messages: 77
Registered: July 2009
Member
Krzysztof,

I browsed some more into the Ecore -> Entity Data Model scenario,

As per
http://social.msdn.microsoft.com/Forums/de-DE/adodotnetentit yframework/thread/b3ec1d1a-7a5c-4b7d-8277-3d6282777b41
the metadata API I was referring to gives read-only access.

The post above goes on to suggest creating an Entity Data Model in terms of
its XML representation.

There's even an XML schema for that represenation! :)
Which goes by the name of System.Data.Resources.CSDLSchema.xsd , and can be
found (after installing VS 2008 SP 1) at:
%VSInstallFolder%\Xml\Schemas


Miguel


--
Miguel Garcia miguel.garcia@tuhh.de
Institute for Software Systems (STS), E-16
Technische Universitaet Hamburg-Harburg
Harburger Schlossstr. 20, 21073 Hamburg Fax: (+49)40-42878-2515
http://www.sts.tu-harburg.de/people/mi.garcia


"Krzysztof Kowalczyk" <kowalczyk.krzysztof@gmail.com> wrote in message
news:gvm234$73g$1@build.eclipse.org...
> Easiest solution IMO:
> Use Ecore with generated XML Schema serialization not with XMI. Then
> export and save Ecore model in "plain" XML and...
>
> Then try what fit best:
> - generate C# classes from XSD and use LINQ to objects - typed, works
> well, but you need to generate C# classes for all XSDs
>
> - LINQ to XSD - it is typed so you use "Library" and "Book", but I am not
> sure how stable this project is
> ( http://www.microsoft.com/downloads/details.aspx?FamilyID=A45 F58CD-FCFC-439E-B735-8182775560AF&displaylang=en)
>
> - LINQ to XML(XLINQ) - it is not typed, so you use "Element" and
> "Attribute", so not that cool, but supported out of the box and mature
>
>
>
> Some less attractive solutions:
>
> 2) Read Ecore XMI in C# model and use LINQ to objects
>
> Read XMI somehow and then use LINQ to objects or even customize LINQ for
> used classes.
> Have you checked EMF4NET?
>
> "XML and XMI serialization
> Next big milestone. The reflective EObject API is working and a simple XMI
> serialization use case is implemented (EClass with attributes can be
> serialized)."
>
> It would be good for the community to have EMF4NET XMI (de)serialization
> and LINQ for EMF4NET :)
>
> 3) Look for, or create LINQ to XMI
>
> One comment below
> >
> > Today I was looking for a way to store Ecore models to be queried using
> > Microsoft LINQ (as to why, that's another story). Having found no
> > ready-made tool, I took a look at the API for retrieving (creating?)
> > metadata for consumption by the Entity Framework,
> > http://msdn.microsoft.com/en-us/library/bb399772.aspx
>
> AFAIK with Entity Framework you would need new C# Class model for each
> Ecore metamodel that you want to read. Hm, it is possible to use Teneo and
> Hibernate, or CDO to generate database schema. Then store the EMF model
> there. To read it you can then:
> - use LINQ to SQL
> - use Entity Framework to generate C# entities from generated database
> schema and LINQ for Entities
>
> but this is quite complicated.
>
> Regards,
> Krzysztof Kowalczyk
Re: EMF -> EF, anyone? [message #430609 is a reply to message #430599] Fri, 29 May 2009 12:32 Go to previous messageGo to next message
Krzysztof Kowalczyk is currently offline Krzysztof KowalczykFriend
Messages: 113
Registered: July 2009
Senior Member
Miguel,

Nice, so You just need to map ".ecore" model to Data Model? Then it
seems to be the solution.

Regards,
Krzysztof Kowalczyk

>
> Krzysztof,
>
> I browsed some more into the Ecore -> Entity Data Model scenario,
>
> As per
> http://social.msdn.microsoft.com/Forums/de-DE/adodotnetentit yframework/thread/b3ec1d1a-7a5c-4b7d-8277-3d6282777b41
>
> the metadata API I was referring to gives read-only access.
>
> The post above goes on to suggest creating an Entity Data Model in terms
> of its XML representation.
>
> There's even an XML schema for that represenation! :)
> Which goes by the name of System.Data.Resources.CSDLSchema.xsd , and can
> be found (after installing VS 2008 SP 1) at:
> %VSInstallFolder%\Xml\Schemas
>
>
> Miguel
>
>
> --
> Miguel Garcia miguel.garcia@tuhh.de
> Institute for Software Systems (STS), E-16
> Technische Universitaet Hamburg-Harburg
> Harburger Schlossstr. 20, 21073 Hamburg Fax: (+49)40-42878-2515
> http://www.sts.tu-harburg.de/people/mi.garcia
>
>
> "Krzysztof Kowalczyk" <kowalczyk.krzysztof@gmail.com> wrote in message
> news:gvm234$73g$1@build.eclipse.org...
>> Easiest solution IMO:
>> Use Ecore with generated XML Schema serialization not with XMI. Then
>> export and save Ecore model in "plain" XML and...
>>
>> Then try what fit best:
>> - generate C# classes from XSD and use LINQ to objects - typed, works
>> well, but you need to generate C# classes for all XSDs
>>
>> - LINQ to XSD - it is typed so you use "Library" and "Book", but I am
>> not sure how stable this project is
>> ( http://www.microsoft.com/downloads/details.aspx?FamilyID=A45 F58CD-FCFC-439E-B735-8182775560AF&displaylang=en)
>>
>>
>> - LINQ to XML(XLINQ) - it is not typed, so you use "Element" and
>> "Attribute", so not that cool, but supported out of the box and mature
>>
>>
>>
>> Some less attractive solutions:
>>
>> 2) Read Ecore XMI in C# model and use LINQ to objects
>>
>> Read XMI somehow and then use LINQ to objects or even customize LINQ
>> for used classes.
>> Have you checked EMF4NET?
>>
>> "XML and XMI serialization
>> Next big milestone. The reflective EObject API is working and a simple
>> XMI serialization use case is implemented (EClass with attributes can
>> be serialized)."
>>
>> It would be good for the community to have EMF4NET XMI
>> (de)serialization and LINQ for EMF4NET :)
>>
>> 3) Look for, or create LINQ to XMI
>>
>> One comment below
>> >
>> > Today I was looking for a way to store Ecore models to be queried using
>> > Microsoft LINQ (as to why, that's another story). Having found no
>> > ready-made tool, I took a look at the API for retrieving (creating?)
>> > metadata for consumption by the Entity Framework,
>> > http://msdn.microsoft.com/en-us/library/bb399772.aspx
>>
>> AFAIK with Entity Framework you would need new C# Class model for each
>> Ecore metamodel that you want to read. Hm, it is possible to use Teneo
>> and Hibernate, or CDO to generate database schema. Then store the EMF
>> model there. To read it you can then:
>> - use LINQ to SQL
>> - use Entity Framework to generate C# entities from generated
>> database schema and LINQ for Entities
>>
>> but this is quite complicated.
>>
>> Regards,
>> Krzysztof Kowalczyk
>
Re: EMF -> EF, anyone? [message #430620 is a reply to message #430609] Sat, 30 May 2009 10:43 Go to previous message
Miguel Garcia is currently offline Miguel GarciaFriend
Messages: 77
Registered: July 2009
Member
Krzysztof,

> Nice, so You just need to map ".ecore" model to Data Model? Then it seems
> to be the solution.

That's the beginning, I also would like to translate OCL into LINQ. A more
detailed discussion takes place at
http://blogs.msdn.com/adonet/archive/2009/05/12/sneak-previe w-model-first-in-the-entity-framework-4-0.aspx

Miguel
http://www.sts.tu-harburg.de/people/mi.garcia/
Previous Topic:CDO2.0.0.v200905261224 - no CDOUtil.prepareContainer, CDO.createSessionConfiguration ?
Next Topic:Teneo: Manually setting id
Goto Forum:
  


Current Time: Thu Apr 25 02:26:56 GMT 2024

Powered by FUDForum. Page generated in 0.02901 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top