0

I recently made my first ASP.NET website with MVC. I selected the option that pre-loads a basic project with login functionality and a few pages. I spent a couple hours learning how it all works and I'm pretty comfortable with most of the features. Now I want to add a class that interacts with the database and I've run into a bit of an issue.

When I search for a solution every response says to use DbContext. I don't think there's necessarily anything wrong with this, but when I search for DbContext and some other commands that show up frequently in these responses, there are no instances of them in the project. I would really like to use the same method of creating models that was done for the account classes, but when I look at the code I'm not entirely sure what I'm looking at as it links to a bunch of different files.

Can I get some tips on how to create classes the way that ASP.NET creates default account models?

For reference: I'm using Web Essentials, Productivity Power Tools and VS 2013.5

1
  • There are numerous of articles available that will help you to learn ASP. NET MVC see this Commented Aug 13, 2016 at 8:37

1 Answer 1

1

There're tons of tutorials online that cover ASP.NET MVC Code First Entity Framework. I start with something like this

http://www.asp.net/mvc/overview/getting-started/getting-started-with-ef-using-mvc/creating-an-entity-framework-data-model-for-an-asp-net-mvc-application

And see where you get to. This is the basic approach:

  • Create the model classes
  • Create the Context
  • Enable Migrations (in case you need to change the model)
  • The SQL Expres database will be built automatically based on your EF classes.

Good luck. It's not as difficult as it first appears once you've done your first one.

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

Comments

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.