How to import database tables to code with Entity Framework 6

Asked

Viewed 274 times

1

In my project, I have only a few entities that are not connected to the database, but I run some procedures through EF6.

These procs are only queries that bring data across information from more than one table.

Now I want to insert into the same project entities and tables repositories that already exist in the database.

How do I import this into code?

  • Wouldn’t be typing?

  • 1

    You can map your database tables to your application using the code first or through the database first

  • Do you use EF to persist the data or just to query VIEWS? And what would be a table repository?

  • when I speak repository, it would be the class that would crud. I will use EF to persist, do Insert and query and show in the view. but I think I’ll create it all in the same hand. is that there are many tables, I thought I would have something more automated.

  • 1

    You can search @Marconciliosouza’s suggestion, with Code First or DB First. You will configure the connection and the EF generates for you the classes (tables) and the context...

  • 1

    @Guilhermecamarotto, you can create a project separately and import your database to a repository through the database first, and then just copy your classes to your own project, the Database First generate the file. edmx which I believe is no longer supported in the Entity Framework Code. Where everything would now be based on Code First, so I advise you to already follow this path.

  • 1

    @Guilhermecamarotto, Code first allows among many things you to create a more friendly model in relation to its properties classes, because many databases have very ugly structures.

  • 1

    Good idea @Marconciliosouza, I will generate in another project and bring to my only what I need. thank you all for the tips.

Show 3 more comments
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.