Unable to Reverse Engineer tables that have a Unique Constraint on a computed column from a database project
See original GitHub issueI 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
- Create a new database project in Visual Studio
- Create a new table with a persisted computed column that has a unique constraint
- Create a new C# project in Visual Studio
- 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:
- Created 4 years ago
- Comments:8 (4 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thanks for reporting this, fixed in the latest daily build
@godfrey-tech By design: https://github.com/ErikEJ/EFCorePowerTools/wiki/Reverse-Engineering#sql-server-database-project-dacpac-mapping