No Entity Framework provider found for the ADO.NET provider with invariant name 'System.Data.SqlServerCe.4.0'

后端 未结 12 2307
失恋的感觉
失恋的感觉 2020-12-05 22:44

I got the following error when I used sqlce 4.0 with entityframework 6.0

No Entity Framework provider found for the ADO.NET provider with invariant name \'Sy         


        
12条回答
  •  醉话见心
    2020-12-05 23:39

    I met the issue in my unit tests. The tricky thing was that the error had appeared not constantly. I managed to solve it by adding the follwing class my my unit tests solution:

    public static class Trick
    {
        public static void FixEfProviderServicesProblem()
        {
            // this commented line should be used for SQL Server provider
            //var instance = System.Data.Entity.SqlServer.SqlProviderServices.Instance;
    
            // this is used for SQL Server CE provider
            var instance = System.Data.Entity.SqlServerCompact.SqlCeProviderServices.Instance;
        }
    }
    

提交回复
热议问题