Cashed code-first model with Npgsql

entity-framework entity-framework-6 npgsql


I'm trying to turn on use of cached entity models (after reading along with Npgsql provider.


Class NpgsqlConfiguration
  Inherits System.Data.Entity.DbConfiguration
  Public Sub New()
    Dim provider = "Npgsql"
    SetProviderServices(provider, Npgsql.NpgsqlServices.Instance)
    SetProviderFactory(provider, Npgsql.NpgsqlFactory.Instance)
    SetDefaultConnectionFactory(New Npgsql.NpgsqlConnectionFactory())

    SetModelStore(New DefaultDbModelStore(Directory.GetCurrentDirectory()))
  End Sub
End Class

At the first run Edmx model is generated, with valid content. However on the second run exception occurs, when i try to get access to some db sets from the context

ctx.Set(Of EntityClass).ToList()

System.ArgumentException: 'The path is not of a legal form.'

How can i overcome this? Thanks for the help.

Entity framework 6.2.0, Ngpsql 4.0.2, ef.npgsql 3.2.0

8/15/2018 8:32:13 AM

Accepted Answer

I'm using Costura.Fody for the solution, and when i've disabled it, EF started to load the generated model.

Hovewer I've didn't notice any significant performance boost :/

  • calling the first query with no edmx model takes about 2.4s
  • calling the first query with edmx model takes about 2.2s

I have 46 entities (tables) in the model, may be it is too small amount to find the effect of caching..

8/16/2018 11:56:47 AM

Related Questions


Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow