0

I have a new MVC website (Internet Application) created using VS 2013.

I come from a Database first background and would like to take this approach for this project.

The project from what i see already has Entity Framework installed but i don't see any Entity Data Model files most likely because the project is Code First by default.

How could i bring the Database First approach in this project (the tables are already created within the database)?

0

1 Answer 1

3

Adopt the "Code First to an Existing Database" workflow, which is really a database-first workflow.

That will allow you to add a generated DbContext that maps to your existing database, without introducing an .EDMX file and the old designer-based database-first workflow.

The old EDMX-based database-first workflow should not be used for new work if you can help it. There's a lot of obsolete design and complexity in the OSpace/CSpace/SSpace mapping that Code-First hides from you, and EF Core has eliminiated entirely. There's some functionality in EDMX that hasn't been replicated in code-first, but there are reasonable workarounds for most of it.

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

4 Comments

Ok I was looking at a similar article earlier which was also using the Entity Data Model Wizard but EF Designer from Database instead of Code First from Database. So I will upgrade EF to v6 then use that option. Could i continue using the scaffolding options to create the CRUD views etc?
I'm not sure if it will scaffold the views automatically. You have to manually assign the key columns on the view in EF6 anyway. So it's at least partially manual. Sometimes when using views heavilly, it's easier to create a dummy database with empty tables with primary and foreign keys and scaffold that. Then at runtime connect to the real database with views.
Great! Finally this new Context can reside in a outside of the Models folder? I will eventually migrate this into a separate Class library once i have this working. Thanks
The new DbContext is just a code file. It can be in whatever folder and whatever namespace you want.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.