tags:

views:

278

answers:

6

In EJB 3.0 you can write your domain objecs, then convert them into entitities (adding @Entity attribute, etc.) and underlying JPA mechanism (let's say Hibernate) can automaticly generate db schema. What's better it will also update db when you update you domain model in Java code.

I'm looking for equivalent of that functionality on .NET platform. Is is possible with ADO.NET Entity Framework?

+1  A: 

Yes - in the future :-) The current Entity Framework doesn't support the "domain-first" approach - but the next version (EF v4) will. This will ship with .NET 4.0 / Visual Studio 2010 - but don't ask me, when! I don't know (neither does Microsoft).

Marc

marc_s
A: 

There are third party frameworks that do this in .NET today.

Cheeso
+2  A: 

Mindscape LightSpeed supports this - full schema round tripping with model first or database first development. It is a commercial product but there is a free version for small databases.

As mentioned, Entity Framework will add some of these features in their next release but that is some time away.

Details of the LightSpeed designer with the model first support

traskjd
+1  A: 

NHibernate is a .NET port of Hibernate, and I think it includes tools for generating database schema for your entities.

Robert Lewis
+2  A: 

Active Record is the way forward! You mark up your objects with attributes and from there you can generate the database schema or the database itself. There is also a tool called Active Writer which allows you to draw the models and it writes the codes with the correct attributes for you.

It is essentially a wrapper for NHibernate but it makes things a bit easier as you do the mapping on the objects rather than in XML documents.

We have used this on several projects and found it to be a fast way of implementing complex systems.

Penfold
+3  A: 

DataObjects.Net also automatically generates and upgrades database schema according to domain model. But the most interesting thing is how to upgrade stored data if model and database schema are changed. Is it possible to do it on entity level, rather then using low-level SQL?

Alex Kofman