Error 3002: Problem in mapping fragments in .EDMX

Malam Malam 226 Reputation points
2024-06-18T06:04:21.64+00:00

I have only one table in model's .edmx file. I updated the table in SQL Server by adding a column to it, opened up the .edmx file and used "update Model from Database" to update. The updated .edmx does show newly added field but I get a compile error:

       Error 3002: Problem in mapping fragments
```How do I fix it without deleting and recreating the model?

ASP.NET
ASP.NET
A set of technologies in the .NET Framework for building web applications and XML web services.
3,389 questions
SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
13,166 questions
0 comments No comments
{count} votes

Accepted answer
  1. Lan Huang-MSFT 28,201 Reputation points Microsoft Vendor
    2024-06-18T07:25:02.84+00:00

    Hi @Malam Malam,

    Check the entity keys in your table. It is the only one.

    This may have happened unexpectedly, or the Entity Framework was unable to get the primary key information from the database and had to infer the entity key.

    If you right-click the column (in EF diagram on VS) you will get the option to tick/untick the Entity Key:

    User's image

    However, it is recommended that you delete the table from your edmx, then "Update Model from Database" and add the table again, and finally rebuild your project.

    User's image

    Best regards,
    Lan Huang


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful