2016-04-12 10 views
1

何らかの理由で私は同じ名前の3種類のテーブルを持つデータベースを持っていますが、接頭辞は異なります。私は手動でのみdbo.SpRicezioneSpedizioniLightテーブルを実装する必要があり、私はこの2つのクラスがあり実現しているEntity FrameworkのConnectionStringが重複したテーブルを持つApp Configにあります

enter image description here

public class SpRicezioneSpedizioniLight 
{ 
    public string AudOperation { get; set; } 
    public Nullable<System.DateTime> AudDateLog { get; set; } 
    public int PROGRESSIVO { get; set; } 
} 

public class GemapDbContext : DbContext 
{ 
    public DbSet<SpRicezioneSpedizioniLight> SpRicezioneSpedizioniLights { get; set; } 
} 

私は特定のテーブルをどのように識別することができますが、データベースのスキーマはこれですdbo.SpRicezioneSpedizioniLight?今のところ、私の接続文字列は:

<add name="SABIntegrationEntities" connectionString="metadata=res://*/Models.ModelTest.csdl|res://*/Models.ModelTest.ssdl|res://*/Models.ModelTest.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=localhost;initial catalog=SABIntegration;integrated security=True;multipleactiveresultsets=True;application name=EntityFramework&quot;" providerName="System.Data.EntityClient" /></connectionStrings> 

これはすべて、1つのテーブルを持つローカルデータベースで正常に動作します。

はあなた

答えて

2

あなたのテーブル名の「接頭辞」このテーブルが関連付けられているスキーマの名前ですありがとうございました。 "dbo"は、EFで使用されるデフォルトのスキーマ名です。

modelBuilder.HasDefaultSchema(SchemaName);を使用して、デフォルトのスキーマを変更できます。 をOnModelCreating-Methodに追加するか、他のタイプを modelBuilder.Entity()を使用して明示的にタイプにマップします。ToTable( "SpRicezioneSpedizioniLight"、 "bak");

関連する問題