question

RodAtWork avatar image
0 Votes"
RodAtWork asked karenpayneoregon answered

Having a lot of problems adding 3 tables to a EDMX file

We use EDMX files whenever using Entity Framework. I had to add three new tables to a .EDMX file a colleague of mine created months ago. However, whenever I did, I got lots of error messages, it refused to add them and instead deleted most of the rest of the tables. I tried deleting the whole .EDMX file and recreating it, but that failed, claiming that an object already existed by the same name.

So now I've tried deleting all tables and views from the .EDMX designer, so I could add them back in, hoping that would work. However, I've got an error that I've never seen before and performing a Bing search doesn't reveal anything. Here's a screen capture of the error:

41397-screenshot-cannot-be-saved-2020-11-20-093807.png


dotnet-entity-framework
· 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.

Thank you, @DanielZhang-MSFT, that helps. However, when I did that I got lots of errors about not being able to find AppEntities within the CoreFramework namespace. When I opened the .EDMX file it was obvious to me that AppEntities was in the correct namespace.

I decided to delete all of the files out of VS 2019 in the Model folder. For extra measure I opened File Explorer and deleted other things that VS 2019 didn't delete. Then I tried to re-create them. That failed really miserably by crashing VS 2019.

42229-2020-11-24.png


0 Votes 0 ·
2020-11-24.png (12.8 KiB)
DanielZhang-MSFT avatar image
1 Vote"
DanielZhang-MSFT answered DanielZhang-MSFT commented

Hi Rod At Work,
Do your three tables have primary keys?
If not, please set Primary Keys to all tables or check "Allow null" check-box in any column of each table.
You can also try the Craig Stuntz's method that going into the XML and look for references to the tables in question.
Here is a related document you can refer to.
Changes Made to an .edmx File by the Update Model Wizard
Best Regards,
Daniel Zhang


If the response is helpful, please click "Accept Answer" and upvote it.

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.

Best Regards,
Daniel Zhang


· 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.

Yes, @DanielZhang-MSFT, all three tables have primary keys.

This is a big problem. I've been unable to make any progress on developing required features since Wednesday of last week, because of having to fight this problem. Here are some of the things I've tried since Wednesday.

  • EDMX file: AppModel.edmx

  • It will replace code in AppModel.cs with 1 string "ErrorGeneratingOutput".

  • It will not recognize that a column has been removed from 2 older tables. When I delete the column from both tables in the EDMX designer, it deletes lots of table files (.cs file) and no longer

I am stuck and can no longer be productive due to these errors.

41879-screenshot-2020-11-23-091812-1.png


0 Votes 0 ·

Hi @RodAtWork,
What version of your EF?
If it is EF6, I guess your problem is that your T4 templates, which generate the entitties and the context are still in EF version 5.
So you need to delete the current code generation items namely <Modelname>.Context.tt and <Modelname>.tt.Next and then add a new EF version 6 code generator.
More details you can refer to boindiil's answer.
Best Regards,
Daniel Zhang


0 Votes 0 ·
DanielZhang-MSFT avatar image
1 Vote"
DanielZhang-MSFT answered

Hi @RodAtWork,
Unknown software exception (0xe0434352) is an error that is related to .NET installation. The majority of the reasons for this error is having a faulty .NET Framework, another reason is because of some corrupted files or old drivers that are contradicting with Windows.
You can try to perform a clean boot in Windows.
If not successful, please try other methods in these threads.
The exception unknown software exception (0xe0434352) occurred in the application at location 0x7702c41f
exception unknown software exception (0xe0434352)
Best Regards,
Daniel Zhang


If the response is helpful, please click "Accept Answer" and upvote it.

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.


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.

RodAtWork avatar image
0 Votes"
RodAtWork answered

Hi @DanielZhang-MSFT,

I've given up on using those .EDMX files. I think they became seriously messed up. I deleted them, then recreated the models using EF's Code First from Existing Database. No errors at all.

Now all I have to do is convince my co-workers that this is a better approach.

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.

karenpayneoregon avatar image
1 Vote"
karenpayneoregon answered

Hello @RodAtWork,

As you certainly learned, EDMX usage can be problematic while using EF code first from database will not cause the current issues. A good way to convince others is to work with EF Core Power Tools (if open to using EF Core). You can reverse engineer databases by right clicking on a project and select EF Power Tools, reverse engineer. If something changes in the database e.g. add a new column you can rerun EF Power tools and it will allow you to update the model(s). On a side note, if you are modifying models e.g. adding read-only properties etc you can always use partial classes placed in a different folder than your models and keep the same namespace.

In regards to Entity Framework vs Entity Framework Core, there are more/better way to do things in EF Core although for the most part existing code should port fine.

Example for selecting tables
43714-ef1.png

Some of the configuration options
43550-ef2.png




ef1.png (13.3 KiB)
ef2.png (26.7 KiB)
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.