连接字符串麻烦MetaDataException [英] Connection String Trouble MetaDataException

查看:96
本文介绍了连接字符串麻烦MetaDataException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的项目有两个型号。当我添加第二个模型,我得到这个错误在所有帐户页面:

I got two models in my project. When I added the second models I got this error in all account page:

System.Data.MetadataException: The specified schema is not valid. Errors:
(8.6): error 0040: the nclob type is not qualified with a namespace or alias. Only primitive types can be used without qualification.

At line 34 of `InitializeSimpleMembershipAttribute.cs` : 

    using (var context = new UsersContext())
Ligne 33 :                     {
Ligne 34 :                         if (!context.Database.Exists())
Ligne 35 :                         {
Ligne 36 :                             // Create the SimpleMembership database without Entity Framework migration schema

和我的那些连接字符串:

and those my connection string :

<connectionStrings>
    <add name="DefaultConnection" connectionString="User Id=devart;Password=1234;Data Source=localhost:1521" providerName="Devart.Data.Oracle" />
    <add name="Entities" connectionString="metadata=res://*/Models.ModelMAE.csdl|res://*/Models.ModelMAE.ssdl|res://*/Models.ModelMAE.msl;provider=Oracle.DataAccess.Client;provider connection string=&quot;DATA SOURCE=localhost:1521;PASSWORD=1234;USER ID=TEST&quot;" providerName="System.Data.EntityClient" />
  </connectionStrings>

的UserContext 连接字符串1:

public class UsersContext : DbContext
{
    public UsersContext()
        : base("DefaultConnection")
    {
    }

    public DbSet<UserProfile> UserProfiles { get; set; }
}

的UserContext 的connectionString 2:

UserContext connectionString 2 :

public class EntitiesMAE : DbContext
{

    public EntitiesMAE() : base("name=EntitiesMAE")
    {
    }

    public DbSet<OFFRE> OFFRE { get; set; }

    public DbSet<REGION> REGION { get; set; }
}

问题在连接Seconde系列字符串实体当我删除它的每一件事情的作品。
请如何解决?

The problem's in seconde connection string entities when I remove it every thing works. Please How to fix it ?

推荐答案

这看起来像它涉及到这个问题:

This looks like it's related to this problem:

http://forums.devart.com/viewtopic.php?t=21488

本文建议使用两种方法。
1.停用约定(我不会推荐)
2.使用OracleEntityProviderConfig配置Workarounds.IgnoreSchemaName =真

This article recommends two approaches. 1.Disable Conventions (I wouldn't recommend this) 2.Use OracleEntityProviderConfig to configure Workarounds.IgnoreSchemaName = true

他们还提到使用特定的DbContext模板,你可以从这篇文章中找到(我讨厌刚刚发布的链接,但有太多的信息,有总结):

They also mention using a specific DbContext Template, which you can find from this article (I hate just posting links, but there's way too much information there to summarize):

HTTP://blog.devart .COM /实体开发商 - EF code-第一的DbContext-template.html

不过,这是为EF 4.1写的,你不说你用的是什么版本的EF ...所以我不知道是否有任何这仍然适用于任何版本你可以使用

However, this was written for EF 4.1, and you don't say what version of EF you're using... so i'm not sure if any of this still applies to whatever version you may be using.

所以要点是,你不能只是没有其他变化更换供​​应商。你将不得不作出一些其他的变化,我会建议使用类似code,看看它产生产生code与DevArt的DbContext模板,然后将其code在您的应用程序。

So the gist is that you can't just replace the provider with no other changes. You're going to have to make some other changes, and I would suggest generating code with the DevArt DbContext template using similar code and see what it produces, then put that code in your app.

另外,你的code显然是错误的。您使用的连接字符串不存在的(你说的连接字符串被称为实体,但你的code将使用称为EntitiesMAE连接字符串),你也说你的第二个方面就是所谓的UserContext,但你的code叫作EntitiesMAE。我建议清理您的code,使其具有自己的真实code,否则我们只是想帮你用code,它是无效的。

Also, your code is obviously wrong. You're using connection strings that don't exist (You say the the connection string is called Entities, but your code is using a connection string called EntitiesMAE), you also say your second context is called UserContext, but your code is called EntitiesMAE. I suggest cleaning up your code so that it has your REAL code, because otherwise we're just trying to help you with code that isn't valid.

这篇关于连接字符串麻烦MetaDataException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆