C# - Entityframework | Database Comparison

Asked

Viewed 78 times

3

I started using EF a short time ago, so I don’t know much about it.

I would like to know if I have how to make a comparison of my class with the database using EF.

Example of comparison:

Staff Class has the following fields:

Code, Name, Zip code, Telephone, City.

In the database in the Employees table, it has the following fields:

Code, Name, Zip code, Telephone, City, State

I wanted an Entity routine that would compare my Employees class to the Employees table, and return me what fields the bank owns, and which my class does not own, and vice versa (class owns, bank does not own).

You know if it is possible to do this, or if the EF only creates the database according to the mapping I did in my class?

1 answer

3

We can use 2 strategies with the RU: Code First and Database First.

Code-First

http://www.devmedia.com.br/entity-framework-code-first/29705

Db-First

http://www.entityframeworktutorial.net/EntityFramework5/create-dbcontext-in-entity-framework5.aspx

From what I understand you are developing an application that already has a database.

In this case you can use the Entity Framework Power Tools. This tool has an option for you to use reverse engineering, that is, from the databank it creates the classes already with the DataAnnotations.

Following link:

https://msdn.microsoft.com/en-us/data/jj593170.aspx

Sorry, I don’t know any tool that compares the database with your classes, but I think the proposed solution will help you.

Browser other questions tagged

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