I am using the JetEntityFrameworkProvider
. I am trying to connect to an MS Access file (it has ext .sep
but it is indeed an Access file).
I am trying to define the connection string and provider in code, but it is not working. Before I run I get the following error:
Unable to determine the provider name for provider factory of type 'JetEntityFrameworkProvider.JetProviderFactory'. Make sure that the ADO.NET provider is installed or registered in the application config.
I do not wish to configure the provider in the config. Surely there is a way to do this.
When I do run it (yes it will build), I get this error:
System.InvalidOperationException: 'The 'Jet OLEDB:Database' provider is not registered on the local machine.'
Context class
public class ProjectContext : DbContext
{
private DbConnection con = new JetConnection();
public ProjectContext() : base(new JetConnection(""Provider=Microsoft.ACE.OLEDB.12.0;Data Source='C:\\Test-Project.sep'; Provider=Jet OLEDB:Database; Password=SEEME;""), true)
{
}
public DbSet<Component> Components { get; set; }
}
Entity class
public class Component
{
[Key]
[Column("Counter")]
public int Id { get; set; }
[Column("Name")]
public string Name { get; set; }
}
I solved this by changing the connection string to this.
public ProjectContext() : base(new JetConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source='C:\Test-Project.sep'; providerName=JetEntityFrameworkProvider; Password=SEEME;"), true)
{
}
However, I have a new problem and a new error so I will post a new question.