0

I am trying to create EDM using Entity Framework's database-first workflow designer. It fails right after starting running with error message

Object reference not set to an instance of an object

However it creates an .edmx model with just 2 files instead of 4: [name].Designer.cs and [name].edmx.diagram. And those 2 files are missing: [name].Context.tt, [name].tt.

I have the latest version of VS (16.10.0) and EF (6.4.4) and store the DB on localhost, however tried to create EDM using different older versions of VS and EF and got the same result. Could I ask you for tip about what is wrong with what I do?

Thanks in advance

Error message

P.S. BTW [name].Designer.cs file contains errors related to a missing references of:

  • System.Data.Entity.Core.Objects.DataClasses.EdmSchemaAttribute,
  • System.Data.EntityClient,
  • System.Data.Objects and
  • System.Data.Objects.DataClasses.

In other words those references just cannot be added for some reason.

Screenshot of VS

UPD. Tried to do the same on another machine with other older version of VS and different versions of EF and the result is the same. And in that case DB was not stored locally.

  • What code is throwing the error exactly? Post it in your question! It would help if we could see how you have this configured. – Timothy G. Jun 05 '21 at 18:21
  • @Alexey Pankratov, "It fails right after starting running with error message", what is your first step about running? Also, based on my search, the reference you mentioned is related to EntityClient Provider for the Entity Framework instead of Entityframework database first. You can refer to the microsoft doc [Database First](https://learn.microsoft.com/en-us/ef/ef6/modeling/designer/workflows/database-first) to know how to use it. – Jack J Jun Jun 07 '21 at 06:34
  • @JackJJun-MSFT Thanks for your advice. I did everything according that approach, but the problem have not gone. Then I checked a type of the project and it was "Console Application" or "Class Library". Those types of project linked to .NET Core 3.1. Tried to do the same with "ClassLibrary (.NET Framework)" project type and everything started working. So that was the root of the problem. – Alexey Pankratov Jun 07 '21 at 16:58
  • @Alexey Pankratov, I am glad to hear that your problem has been solved. You can make an answer and click '✔' to accept it as an answer. It will also help others to solve the similar issue. – Jack J Jun Jun 08 '21 at 05:37

1 Answers1

0

If there are some inconsistencies between types of project containing Entity Relationship Data Model (.edmx item) and target project, it could cause such illogical error as one mentioned above. So it is always better to check out, whether ERDM containing project and target project do link to the same version of .NET Framework, respectively .NET Core.