Error 3002: Problem in mapping fragments

This error generally occur when you change database (For example changing the primary key) and after it update project entity model.

You can see that all columns in model table were changed like primary key.

To solve the problem, you can select the columns that are not the primary key and change the field “Entity Key” to false.


Or in the properties




Transaction with Entity Framework

Transactions are to locked the database while your system perform many inputs and it can not be edit¹ at this moment, but if one error occur, you can do a rollback “Ctrl+z”.

For more details, you can found here.

The basic Structure

04-07-2017 10-48-20

1- Only the table in use is locked;

Error in Connection String

If you are creating a DLL using #EntityFramework (EF Designer from database) be careful of your Connection String.

#Entity creates the connection string in DLL and it will compile perfectly. but when you import the DLL in a project never forget to reference the same connection string in project’s “App.config” file too, because at system startup, the DLL’s “App.config” file will be replaced by project’s “App.config” file.

Entity Framework – DBContext

Propriedades do Entity Framework

Entidades de uma aplicação que utiliza o Entity Framework, são administradas por um objeto do tipo DbContext. Esse objeto é  responsável  pelas inserção, remoção, alteração e consulta na Database. Ao definir seu método de contexto, faça herança do DBContext. Veja o exemplo:

namespace MyApplicationTest


         public class MyContext : DbContext