我的项目中有两个模型。当我添加第二个模型时,我在所有帐户页面中都出现了此错误:
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
和我的连接字符串:
<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="DATA SOURCE=localhost:1521;PASSWORD=1234;USER ID=TEST"" providerName="System.Data.EntityClient" />
</connectionStrings>
usercontext
连接字符串1:
public class UsersContext : DbContext
{
public UsersContext()
: base("DefaultConnection")
{
}
public DbSet<UserProfile> UserProfiles { get; set; }
}
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连接字符串entities
中的问题一切正常。
请问如何解决?
答案 0 :(得分:0)
这看起来与此问题有关:
http://forums.devart.com/viewtopic.php?t=21488
本文推荐两种方法。 1.Disable Conventions(我不推荐这个) 2.使用OracleEntityProviderConfig配置Workarounds.IgnoreSchemaName = true
他们还提到了使用特定的DbContext模板,你可以在这篇文章中找到它(我讨厌发布链接,但是有太多的信息需要总结):
http://blog.devart.com/entity-developer-ef-code-first-dbcontext-template.html
但是,这是为EF 4.1编写的,你没有说你正在使用的是什么版本的EF ...所以我不确定这些是否仍然适用于你可能使用的任何版本。< / p>
因此,要点是您不能只更换提供者而不需要其他更改。您将不得不进行一些其他更改,我建议使用类似的代码使用DevArt DbContext模板生成代码并查看它产生的内容,然后将该代码放入您的应用程序中。
此外,您的代码显然是错误的。您正在使用不存在的连接字符串(您说连接字符串称为实体,但您的代码使用名为EntitiesMAE的连接字符串),您还说您的第二个上下文称为UserContext,但您的代码称为EntitiesMAE 。我建议清理你的代码,使其具有你的真实代码,否则我们只是试图帮助你使用无效的代码。