Unit testing Entity Framework 6 with context inheritance from IdentityDbContext

I am looking for unit testing some methods using Entity Framework 6 using the instructions provided here .

My setup is a little different, although I also use the ASP.Net identifier (the default implementation using EF). So my context is inherited from IdentityDbContext.

When I run the tests, I get an exception with the following details:

Castle.Proxies.IdentityUserLogin: : EntityType 'IdentityUserLogin' has no key defined. Define the key for this EntityType.    
Castle.Proxies.IdentityUserRole: : EntityType 'IdentityUserRole' has no key defined. Define the key for this EntityType.    
IdentityUserLogins: EntityType: EntitySet 'IdentityUserLogins' is based on type 'IdentityUserLogin' that has no keys defined.    
IdentityUserRoles: EntityType: EntitySet 'IdentityUserRoles' is based on type 'IdentityUserRole' that has no keys defined.

I read that for normal purposes they are configured by default for the OnModelCreating method.

But can anyone offer advice on handling this within the ridiculous context illustrated in the method associated with the above?

thank

Andy

+4
1

, EF, : LINQ-to-Objects, LINQ-to-SQL. , , , , . :

context.Foos.Where(candidate => SomePredicate(candidate));

, LINQ-to-SQL , , . ? ? , - , EF, , , , .

, , Gateway, DbContext .

class FooGateway : IFooGateway
{
    IEnumerable<Foo> GetFoosThatObeySomePredicate() { /* ... */ }
}

Gateway , . , , , , Gateway: , .

0

Source: https://habr.com/ru/post/1537286/


All Articles