Where to find .csdl, .ssdl, and .msl files in Entity Framework 4.0 code first?

﹥>﹥吖頭↗ 提交于 2020-05-28 22:29:02

问题


I want to run tests with Effort and to do that I need to specify a connectionstring that also contains a reference to .csdl, .ssdl, and .msl files. The (non-working) connectionstring looks like this now:

<add name="SQLAzureConnection" connectionString=
 "metadata=res://*/Model.projectContext.csdl|
res://*/Model.projectContext.ssdl|res://*/Model.projectContext.msl;
  provider=System.Data.SqlClient;
  provider connection string=&quot;Data Source=(LocalDb)\v11.0;Initial Catalog=Database_Nieuw;Integrated Security=false;MultipleActiveResultSets=False&quot;"
 providerName="System.Data.EntityClient" />

The Model.projectContext part are wrong but I do not know what it should be.

When I use this string I get the following error on a test that uses this connectionstring to make a mock database connection with Effort.

Test: failed
Result Message: Initialization method  
project.Tests.Controllers.ShoppingCartTest.Initialize threw exception. 
System.InvalidOperationException: System.InvalidOperationException: Resource res://*
/Model.seashell_brawl_corveeContext.csdl not found..

I have no idea where I can find this .csdl file, I only know it is necessary. I cannot create them from my .emdx file because I have a code first database, and right clicking in designer does not give the option to Update database from model as another question gave as a solution. I also set the Metadata Artifact Processing" option to "Embed in Output Assembly.

Does anyone know where I can find these files and how I can reference them correctly?

/Edit:

Alright, it is clear to me now that the files do not exist in code first projects. By using the tip of user20... below in the comments the connection string seems to work now. A new issue is the following:

`Test Outcome:  Failed  error 0040: The Type date is not qualified with a namespace or 
alias. Only primitive types can be used without qualification.` 

Very strange, since I use [DataType(DataType.DateTime)] everywhere. Does anyone know how to solve this?


回答1:


As user3038092 explained:

When using Code First you do not have a .csdl, .ssdl and .msl. The connection string differs also. Basically the correct connection string is what is described as "provider connection string" within your current connection string

that solves the problem.



来源:https://stackoverflow.com/questions/20331107/where-to-find-csdl-ssdl-and-msl-files-in-entity-framework-4-0-code-first

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!