开发者

Entity Framework: Generating database from classes

Is it possible to create the database from the classes with entity framework 4.0? I found many tutorials on how to do it the other way round. But since we have already implemented and tested all classes of the 开发者_JS百科domain we'd like to avoid changing them to much. If I used the wrong keywords in Google I'd appreciate you could post a link.

Cheers, CA


Yes, it is possible. The approach is known as "model-first".

You define your entities with designer then call for "Generate database script" or something. Run this SQL against a database and it will create tables and relationships.


This is quite easy to do with Fluent NHibernate using Auto Mapping. You could also use Fluent Mapping if you want more control over how your entities are mapped, but this will require writing mapping classes. It shouldn't affect your existing classes though.


While looking up an other question on Stackoverflow I found an the solution for my problem: Entity Framework 4 / POCO - Where to start?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜