question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unable to Reverse Engineer tables that have a Unique Constraint on a computed column from a database project

See original GitHub issue

I receive an error when reverse engineering a database whenever I included a table that has a unique constraint on a persisted computed column.

I understand that computed columns cannot be derived from the dacpac file, so the tools probably aren’t able to locate the column in the metadata for the unique constraint, but ideally this shouldn’t cause the entire reverse engineer process to error out (maybe throw a warning?).

Steps to reproduce

  1. Create a new database project in Visual Studio
  2. Create a new table with a persisted computed column that has a unique constraint
  3. Create a new C# project in Visual Studio
  4. Reverse engineer the table from the database project

The Build Output has the following stack trace:

System.InvalidOperationException: Sequence contains no matching element
   at System.Linq.Enumerable.Single[TSource](IEnumerable`1 source, Func`2 predicate)
   at ReverseEngineer20.SqlServerDacpacDatabaseModelFactory.GetUniqueConstraints(TSqlTable table, DatabaseModel dbModel)
   at ReverseEngineer20.SqlServerDacpacDatabaseModelFactory.Create(String dacpacPath, IEnumerable`1 tables, IEnumerable`1 schemas)
   at Microsoft.EntityFrameworkCore.Scaffolding.Internal.ReverseEngineerScaffolder.ScaffoldModel(String connectionString, IEnumerable`1 tables, IEnumerable`1 schemas, String namespace, String language, String contextDir, String contextName, ModelReverseEngineerOptions modelOptions, ModelCodeGenerationOptions codeOptions)
   at ReverseEngineer20.EfCoreReverseEngineer.GenerateFiles(ReverseEngineerOptions reverseEngineerOptions)
   at EFCorePowerTools.Handlers.ReverseEngineerHandler.<ReverseEngineerCodeFirst>d__2.MoveNext() in C:\projects\efcorepowertools\src\GUI\EFCorePowerTools\Handlers\ReverseEngineerHandler.cs:line 193

Further technical details

EF Core Power Tools version: 2.2.12

Database engine: N/A (using SSDT Database project in Visual Studio)

Visual Studio version: Visual Studio 2019

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
ErikEJcommented, Apr 24, 2019

Thanks for reporting this, fixed in the latest daily build

Read more comments on GitHub >

github_iconTop Results From Across the Web

EF core Invalid column name after reverse engineering ...
I have an API using ASP.NET Core 6 & EF6 and I reverse engineered my database (SQL Server) using the EF Core Powers...
Read more >
ORA-00001: unique constraint (XXXX.AK_REV_COL) violated ...
ODI 12c Selective Reverse Engineering operation for certain tables fail with the following error: If the Reverse Engineering Knowledge Module ( ...
Read more >
SQL Server Unique Constraints for Large Text Columns
We are storing large text and URLs that are over 900 bytes in some of our tables and have a requirement to enforce...
Read more >
pgModeler - PostgreSQL Database Modeler
A generated column, according to PostgreSQL docs, "is a special column that is always computed from other columns. Thus, it is for columns...
Read more >
select * from t; -- but don't want virtual columns
Suppose you had a backup for a table with 50 columns insert into bkup ... UNIQUE constraint failed: t.y sqlite> insert into t...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found