zzzprojects / EntityFramework-Effort

Entity Framework Effort is a powerful tool that enables a convenient way to create automated tests for Entity Framework based applications.
https://entityframework-effort.net/
MIT License
431 stars 99 forks source link

In memory db ignores Unique Index #199

Closed antonlq closed 4 years ago

antonlq commented 4 years ago

Hello, I don't really know if this is just a question or an issue so I'm sorry if this is posted in the wrong place.

We have issues with our unit testing. We use Entity Framework and have some migration scripts that have added some Unique Indices in our database which are working fine. But when we're using Effort and testing against the in memory database we get mixed results.

First I'm going to show you code from a migration script where the Unique Index is working correctly in our unit testing: CreateIndex("dbo.Table", "Number", unique: true, name: "IX_Number");

And here is code where the Unique Index is not working when testing against the in memory database: this.Sql("CREATE UNIQUE NONCLUSTERED INDEX IX_Id_NotNull ON [dbo].[Table](TestId) WHERE TestId IS NOT NULL");

In the latter scenario we don't get an Unique Key Violation exception if we are inserting some TestId that already exists.

Is there any issue regarding in memory database with creating an Unique Index the way it's done in the latter case?

Best regards

JonathanMagnan commented 4 years ago

Hello @antonlq ,

In the second case, you try to create the index via SQL Syntax.

However, Effort is not a real SQL database. So it's probably skipped and nothing is created.

Best Regards,

Jon


Performance Libraries context.BulkInsert(list, options => options.BatchSize = 1000); Entity Framework ExtensionsEntity Framework ClassicBulk OperationsDapper Plus

Runtime Evaluation Eval.Execute("x + y", new {x = 1, y = 2}); // return 3 C# Eval FunctionSQL Eval Function