question

BMA-8026 avatar image
0 Votes"
BMA-8026 asked JackJJun-MSFT commented

Entity Framework ADO.net Entity Data Model not working

Hello ,

I observed that when I wand to add a new Model created from database is not working.
Can you see in the attached .gif that Add New Item is in an infinite loop.
Is something missing?
228366-gif.gif


dotnet-entity-frameworkdotnet-adonet
gif.gif (1.8 MiB)
· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@BMA-8026, Welcome to Microsoft Q&A, Could you tell me the vesion about your current app and the version of vs 2022? It will be better for me to make a test, As usual, we used sql server for it, could you use sql server to make a test to check if it still exists the same problem?

0 Votes 0 ·

Since problem appear I installed updates but is still no working.
Tested with SQL Database and it works.

Right now I use :
Microsoft Visual Studio Community 2019
Version 16.11.17
VisualStudio.16.Release/16.11.17+32630.194
Microsoft .NET Framework
Version 4.8.04084


EntityFramework 6.4.4
MySql.Data.EntityFramework 8.0.30
MySql.Data 8.0.3
MySql.Data.Entity 6.9.8


Best regards,

0 Votes 0 ·

1 Answer

BMA-8026 avatar image
0 Votes"
BMA-8026 answered JackJJun-MSFT commented

Hello,
I solved partially my problem using these steps:
1. I deleted old Edmx file and connection string linked to MySQL server
2. I changed target framework from 4.5 to 4.7.2
3. I update EntityFramework , MySql.Data and MySql.Data.EntityFramework to the latest version
4. I checked and manually changed assembly reference target version to version installed
After all changes I thin that the problem was that assembly reference not updating correctly.
Right now I observed that the diagram is not updated correctly (primary and foreign keys and references between tables).
Also I observed that DDL Generation Template is automatically selected to SSDLToSQL10.tt (VS), but I use MySQL.
Referring to this I have the following error :

Error 6002: The table/view 'def.datap.stare_echipamente' does not have a primary key defined. The key has been inferred and the definition was created as a read-only table/view. DataPlanModel.edmx 1



228949-template.jpg



template.jpg (25.0 KiB)
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@BMA-8026, thanks for the feedback, the error means that you didn't define a primary key for the related table. You could try to define a key for that table, like the answer in the question Entity Framework Code First to Existing Database Error 6002.


0 Votes 0 ·