0

I recently imported my database with Entity Framework, and it created models for me. I don't know how to use the types that I got from this. Here is what my model is:

enter image description here

For my other model, named ShoppingModel, I call the classes in the model with `ShoppingModel.Customer', for example.

I can't call these classes this simply here because they aren't direct paths in EntityModel, but I also can't call them doing EntityModel.ShoppingModel.ShoppingDbContext.Customer to use the type of variable. Is there a way to call these types? I need to use them for my project.

Thank you for help!

edit:

I am trying to create a mapping between two variables. I want to put data into one of my entity objects, and then map it over to my normal object, which I call the Shopping Object.

Here, I am using my ShoppingModel's Customer variable. I want to use my EntityModel's Customer variable, but it's not quite as simple as saying 'EntityModel.Customer'.

Mark Hollis
  • 151
  • 1
  • 13
  • 1
    Please show some code that demonstrates what you try to achieve. Your description is full of vaguely defined terms. "I call the variables" / "these variables" - which variables? "direct classes" - what's a direct class? Etc. – Gert Arnold Jul 13 '18 at 21:03
  • Sure thing, and I apologize for that. I'll make an edit, I'm not very good at explaining this sort of thing. – Mark Hollis Jul 13 '18 at 21:09
  • Again, what are you trying to achieve? The structure of your question makes it very hard to follow your intentions. – DevilSuichiro Jul 14 '18 at 08:36
  • Look, you've got three entity classes there, `Customer`, `Item`, and `Order`, and a context class `ShoppingDbContext`. You can use them for anything you can do with any class in C#. Your question and the lack of tentative code make me doubt whether you even have the required basic C# skills to understand where to start. – Gert Arnold Jul 14 '18 at 11:03
  • How do I call the classes under DbContext? I just want to make a variable of this type, but it's not as simple as saying EntityModel.ShoppingModel.ShoppingDbContext.Customer and that's where I was hoping you could help me call this class, because I don't know how to do it. – Mark Hollis Jul 16 '18 at 13:48
  • Customer is just a [POCO](https://stackoverflow.com/questions/16075245/what-is-poco-in-entity-framework). You load it via the context. See the first 3 steps [here](http://www.entityframeworktutorial.net/basics/context-class-in-entity-framework.aspx). So for example, `var myCustomer = context.Customers.FirstOrDefault(c => c.CustomerId == 1);` – Steve Greene Jul 16 '18 at 14:47

0 Answers0