8

How can I programmatically generate Entity Framework classes from a database and then automatically compile them?

I'm looking for a solution that takes a simple connection string and generates a C# library. Exactly what Visual Studio's entity designer does but programmatically.

1
  • Did you find any ways to generate EF classes in database-first applications? After years actually! Commented Feb 22, 2019 at 15:45

1 Answer 1

5

You are looking for Entity Framework power tools.

With that you can create a code first database from a connectionstring (Reverse Engineer Code First ).

With Reverse Engineer Code First you get the code first classes + mapping classes. You can even modify the templates used for the process. All the information you need can be found in the above link.

Sign up to request clarification or add additional context in comments.

3 Comments

This looks really good but it's a visual studio extension. Is there any way to Reverse Engineer Code First programmatically?
Not that I know. But why programmatically if I may ask? This is something you do once. What is your goal? Creating a tool that does this?
It looks like this visual studio extension is open source. So this is exactly what I need. Thanks!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.