After adding Index attribute with IsUnique set to true for string value in my code first model [Index(IsUnique = true)] public string Email { get; set; } , I've tried to update my database, but got following error: "column in table is of a type that is invalid for use as a key column in an index". I've got this error because unique constraint can't be over 8000 bytes per row and will only use the first 900 bytes even then so the safest maximum size for my field would be 450 characters. To add th...
Unit test Data Access Layer (Entity Framework) with in-memory database
Unit testing code that uses data from database is a difficult task. If you use Entity Framework you can stub your data with Effort - in-memory Entity Framework data provider. David Bywaters describes how to use Effort if your create you context based in DbContext class. But if you use model first approach (.edmx already exists) you can follow this guide: First of all install Effort from NuGet: Install-Package Effort -Pre Then add add App.Config file to your unit test project. App.Config file sho...