Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6334055
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T18:35:08+00:00 2026-05-24T18:35:08+00:00

I am struggling to find proper, accurate or well explained documentation for specific Entity

  • 0

I am struggling to find proper, accurate or well explained documentation for specific Entity Framework questions, but I am developing an application that will support multiple types of databases. Originally it was built on DLinq, but now we are adding support. We’ve tried to develop our own system which worked, but was slow, IQToolkit, and now Entity.

My question is, how do you use a single ObjectContext to support multiple types of databases? In the build where we used DLinq originally, there are DatabaseContext instantiations all over the place as its a per transaction item. When we tried IQToolkit, we were able to abstract the calls into our static Shell class that can do ‘Shell.Database.DoSomething’ where ‘Shell.Database’ was a database-independant object that didn’t care what database it was talking to, the framework did all the work. Now we are trying to learn Entity Framework for a better solution, but what I don’t want to do is have code everywhere in the application that has to instantiate a different context based on the configured database. It would be easy to have a single abstracted object that does that work under the hood, so there is only a single object being used for the database work, which I thought was the point of ObjectContext. However, we are running into small problems.

To remedy our learning, I have a test project to learn Entity with a simple Customers table like so:

enter image description here

As you can see, I am using a single EDMX model that defines the schema, and I have separate metadata files for each database type. Originally the EDMX was created by selecting an existing MySQL database The MSSQL version of Northwind has the same schema, except the MySQL schema uses varchar(36) for the GUID since there is no Guid primitive in MySQL. The way I am instantiating this is as follows:

private static void InitMySql() {
    MySqlConnectionStringBuilder builder1 = new MySqlConnectionStringBuilder();
    builder1.Server = "win-x58";
    builder1.Database = "Northwind";
    builder1.UserID = "root";
    builder1.Password = "<password>";

    EntityConnectionStringBuilder builder2 = new EntityConnectionStringBuilder();
    builder2.Metadata = @".\Metadata\MySQL\";
    builder2.Provider = "MySql.Data.MySqlClient";
    builder2.ProviderConnectionString = builder1.ToString();

    m_Context = new NorthwindObjectContext(builder2.ToString());
}

private static void InitMSSql() {
    SqlConnectionStringBuilder builder1 = new SqlConnectionStringBuilder();
    builder1.DataSource = "win-x58";
    builder1.InitialCatalog = "Northwind";
    builder1.IntegratedSecurity = true;

    EntityConnectionStringBuilder builder2 = new EntityConnectionStringBuilder();
    builder2.Metadata = @".\Metadata\MSSQL\";
    builder2.Provider = "System.Data.SqlClient";
    builder2.ProviderConnectionString = builder1.ToString();

    m_Context = new NorthwindObjectContext(builder2.ToString());
}

Now the MySQL connections, and works. I can query the database and see results. However, when I attempt to do this when its instantiated using the MSSQL connection string using this code:

foreach (Customer item in m_Context.Customers) {
    Console.Out.WriteLine(item.Name);
}

I get the following exception:

MetadataException
Schema specified is not valid. Errors: 
Entities.ssdl(10,6) : error 0040: The Type guid is not qualified 
with a namespace or alias. Only PrimitiveTypes can be used without qualification.

The SSDL for MSSQL is:

<?xml version="1.0" encoding="utf-8"?>
<Schema Namespace="northwindModel.Store" Alias="Self" Provider="System.Data.SqlClient" ProviderManifestToken="2008" xmlns:store="http://schemas.microsoft.com/ado/2007/12/edm/EntityStoreSchemaGenerator" xmlns="http://schemas.microsoft.com/ado/2009/02/edm/ssdl">
  <EntityContainer Name="northwindModelStoreContainer">
    <EntitySet Name="Customers" EntityType="northwindModel.Store.Customers" store:Type="Tables" Schema="northwind" />
  </EntityContainer>
  <EntityType Name="Customers">
    <Key>
      <PropertyRef Name="ID" />
    </Key>
    <Property Name="ID" Type="guid" Nullable="false" />
    <Property Name="Name" Type="varchar" MaxLength="45" />
    <Property Name="Email" Type="varchar" MaxLength="45" />
    <Property Name="Phone" Type="varchar" MaxLength="12" />
  </EntityType>
</Schema>

So, maybe I am not understanding EF well. I could really use some good direction to try and remedy all of these design and code problems. I know this is very long and possibly subjective, but I am not sure if one part of my questions or valid because our experience with EF is so little, and I have scoured for good answers and they are incomplete, vague, or non-existant.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T18:35:09+00:00Added an answer on May 24, 2026 at 6:35 pm

    Guid is not a SQL Server database type; hence the error.

    A Guid in SQL Server parlance is uniqueidentifier

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I keep hearing about the Entity Framework fluent-api but I am struggling to find
I've been struggling to find a framework/IDE/GUI designer that suits my current needs. I'm
I'm struggling to find the right terminology here, but if you have jQuery object...
I'm struggling to find a good reference application for ASP.NET MVC. By reference, I
I'm struggling to find a decent walkthrough for this issue, and was hoping that
I am struggling to find a working query in SQLite, that will return my
I thought developer tools could do this but I'm struggling to find it. Any
been struggling to find a way to configure Tomcat 7.0.11 so that my web
I am struggling to find a way to create the Forms functionality that I
I'm new to PL-SQL, and struggling to find clear documentation of operations are nested

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.