0

I started an ASP.NET MVC4 Web App with EF5 and the Db First approach. Now i´ve moved my Models and Context into a MyApp.DataAccess Class Library Project. I added a MyApp.DataAccess reference to MyApp.Web. What do I have to do with my Web.config and especially this section:

<connectionStrings>
    <add name="DefaultConnection" providerName="System.Data.SqlClient" connectionString="Data Source=..." />
    <add name="MyOldEntities" connectionString="metadata=res://*/Models.OldDbModel.csdl|res://*/Models.OldDbModel.ssdl|res://*/Models.OldDbModel.msl;provider=System.Data.SqlClient;provider connection string='data source=&quot;<MyDbServerIp, MyPort>&quot;;initial <LoginData>;MultipleActiveResultSets=True;App=EntityFramework'>" providerName="System.Data.EntityClient" />
  </connectionStrings>

edit: error message: Unable to load the specified metadata resource

Frank
  • 1,113
  • 3
  • 14
  • 27
  • erm nothing? I use this approach in all projects, why do you think you need to change anything? Is something not working? – Ashley Medway Feb 11 '16 at 10:35
  • well, i started with all layers in one project. Now i moved my data stuff into a new class library project and generated a new DbContext. My added reference lets me access all my object but my settings are not working anymore. Can i generate a new web.config based on my new references or is it automatically updated when i add references? There might be also a namespace issue... ErrorMsg is `Unable to load the specified metadata resource` – Frank Feb 11 '16 at 10:45
  • You haven't actually included the full connection strings so its hard to tell whats wrong if I can't see it. – Ashley Medway Feb 11 '16 at 11:43

1 Answers1

0

based on this answer, i have to change

connectionString="metadata=...App=EntityFramework'"

to

connectionString="metadata=...application name=EntityFramework'"
Community
  • 1
  • 1
Frank
  • 1,113
  • 3
  • 14
  • 27
  • I'd say that answer is wrong, you shouldn't even need an app.config the web.config should be used by the separate assembly. – Ashley Medway Feb 11 '16 at 11:40
  • i havent accepted an answer yet, so im up for other solutions. My edmx file was in `MyApp` and now is in `MyApp.DataAccess`. Btw this answer works. – Frank Feb 11 '16 at 11:44