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

8.3k views Asked by At

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

There are 1 answers

4
user2609980 On BEST ANSWER

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.