I have a project that is using Entity Framework Code First but with an Existing Database. So far I have been creating the class for each existing table accordingly and it's all worked out great. What would be brilliant is if there was some way to quickly generate a table to a class to save time on manually coding each class, any ideas? I want to stay with Code First so please don't suggest alternatives, thanks.
-
So you want to use code first but generate your code? Seems like a chicken/egg problem.D Stanley– D Stanley2013-03-09 23:07:52 +00:00Commented Mar 9, 2013 at 23:07
-
I want to use Entity Framework but code only. Everywhere I look online defines this as "Entity Framework Code First with an Existing Database".user1166905– user11669052013-03-09 23:16:12 +00:00Commented Mar 9, 2013 at 23:16
Add a comment
|
1 Answer
You can use EF database first - that will generate .cs classes you can use as a base. Just copy the CS code and then delete the EF database first stuff.
2 Comments
user1166905
As in create a seperate project to generate a one off set of classes, that does seem quite a simple and easy solution. Can you generate the class one table at a time with Database First or do you have to do all?
Prescott
Sure you can do one table at a time or select them all to get it done with. The GUI with EF is extremely easy to use. You don't have to make it in another project - but that will keep your configs clean.