c# - Is it possible to have a EF Context for MySql and SqlServer? -
I have references to two body structure, one for MySQL and one for SQL. If I run the app, I get the following error
The default DB configuration example was used by the unit framework before searching for 'MySQLFFC Configuration' type.
However, if I find the database type at the beginning of the app, then call it Database.SetInitializer
My MySQL context
[Definition type (typef (MySQLifference)) Public class zipcode scheme: DBCOntax {public DBset & lt; Zipcode & gt; Zipcode {get; Set; }}
My General Context
Public category MyContext: DbContext {public DbSet & lt; MyClass & gt; MyClasses {get; Set;}}
and finally the Entity Framework section
& lt; EntityFramework & gt; & Lt; DefaultConnectionFactory type = "System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" /> & Lt; Providers & gt; & Lt; Provider invariantName = "MySql.Data.MySqlClient" type = "MySql.Data.MySqlClient.MySqlProviderServices, MySql.Data.Entity.EF6" /> & Lt; Provider invarianatName = "System.Data.SqlClient" type = "System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" /> & Lt; / Providers & gt;
I hope it is clear, I'm beating my head at the desk
There were 2 different references in the form of variables in my Uow.cs as a result of Object Initialization, the first reference DBC configuration was silently installed, when I was only interested in other reference. As a result, the second reference does not respond to the same error unless I change the design. More information - I have updated the code to use the same reference for Oracle and MS SQL editions. To provide Correspondent DB configuration, I have added custom config class in the same assembly with reference and used it with the DBC configuration type feature. There may be something like this in your case:
public class CustomDbConfiguration: DbConfiguration {public CustomDbConfiguration () (if (DbChecker.MySqlInUse) set configuration (new MySqlEFCconfiguration ());}}
and trying to apply it to both contexts
Comments
Post a Comment