开发者

Is there any easy way to generate the Entity Framework Code-First classes?

The method - Entity Framework Code-First - looks good. But its very difficult to create all the classes for a large database.

Is there any easy way to gen开发者_Python百科erate the Entity Framework Code-First classes?


You can use the recently released Entity Framework Power Tools CTP1. The tool gives you the ability to reverse engineer code first, meaning the Database will be mapped to Code.

Note that all tables in your large database will be mapped. There currently is no way to choose which tables will be mapped to code. Reading through the comments, this feature will most likely be implemented in a future release.


The point of EF Code-First is that you define your domain model in code, then your user-interface and database can be easily generated from that domain model. This has a number of advantages including reducing the amount of tedious code which needs to be written, and helping to ensure your database, your domain model, and your UI match each other.

However, at some point you are going to have to write your domain model - there's no way that can be "generated" (by which I assume you mean computer-generated) as it is personal to your application.

If I've misunderstood your question, please leave a comment and I'll update my answer.


If you want to use the code-first model, but already have an existing database, you can use the Entity Framework Power Tools to generate classes.

If you're reading this after May/2012, the above tool may be out of beta!


No there is no way to generate classes for you if you are using code-first. Code first means that there is no model and no database so you can't generate classes unless you have some upfront design in any case system (UML) which will autogenerate code for you. Simply generating classes without any input about how they should look like sounds like AI from Sci-fi, doesn't it?

If you already have databse you are not using code first but database first. In such case you can have your classes generated.


Check out the link below. It's a program that will generate POCO classes from your databases. I think that's what you're looking for.

http://msormcodegen.codeplex.com/


Generate the code from the database first using database first generation and then modify the resulting code to start your code first version

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜