0

I'm trying to set up Entity Framework 6 in my project to facilitate the programming. However, I'm facing some kind of weird trouble.

I tried to follow this tutorial but with my own DB. http://www.aspsnippets.com/Articles/Simple-Entity-Framework-Tutorial-in-ASPNet-Web-Forms-with-example.aspx

As I tried to create an ADO Entity Data Model, everything worked fine and I got my model done. I'm able to see it in the model explorer. However, I'm not getting anything in my "Models" folder, and I cannot add a reference to my model in my using statements. Which makes me not able to create the kind of functions as described in the tutorial.

Has anyone a clue about how to solve this?

3
  • 1
    Database First is kind of going out the window. If you're learning Entity Framework for the first time, why not look at Code First? Commented Jan 22, 2016 at 2:10
  • DB First isn't going away, just in the form it currently works. DB First tooling is on the roadmap for asp.net 5. Commented Jan 22, 2016 at 2:14
  • You don't have to have the classes always in the Model folder. You should be able to refer to classes in other folders/referenced projects. What you see in the model dropdown list for view are all visible classes. Use the namespace and the class name. e.g. @model <Namespace>.<ClassName> Commented Jan 22, 2016 at 2:40

1 Answer 1

1

Using EF with Database First or EDMX First will hold you back while learning Entity Framework. The best way to learn it is from the ground up, using Code First. DB or EDMX First only really come into play when you're reverse engineering old databases, and even in these cases, you'd be better to rewrite the database in Code First and phase out the old one.

There is a really good tutorial I've found here: Entity Framework Code First End to End. It teaches best practices, as well as going into detail about how and why it all works. It's one of the best ways you can spend 75 minutes when learning Entity Framework.

Start off small, and build outwards. In EF7, they are phasing out the EDMX, so even when working with Database First, you'll need to know everything about Code First in order to make it all work properly. The scaffolded code generated by Database First is really badly written, and needs refactoring as soon as it lands. You'll be refactoring and adapting the code anyway, so Code First is,in most cases, more straightforward.

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.