EF 4.1 OnModelCreating not called

前端 未结 1 1624
梦毁少年i
梦毁少年i 2020-12-06 01:15

I have a problem with EF 4.1 not calling OnModelCreating so that I can configure tables etc. I have an existing database. Here is my connection string:

<
相关标签:
1条回答
  • 2020-12-06 01:22

    You are using two approaches together - your connection string says that you want to use model first or database first with EDMX but you are writing context to use code first / fluent api to map database. Once you use EDMX OnModelCreating is never called. Use common SQL connection string without metadata resources if you want to use OnModelCreating.

    <add name="AcmeDBContext"
         connectionString="data source=[server];
                           initial catalog=Acme;integrated security=True;
                           multipleactiveresultsets=True;App=EntityFramework"
         providerName="System.Data.SqlClient" />
    
    0 讨论(0)
提交回复
热议问题