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

c# connection-string edmx entity-framework vs-unit-testing-framework

Question

I need to specify a connectionstring that also has a reference to Effort in order to run tests with it..csdl,.ssdl , and.msl files. The connectionstring currently has the following appearance:

<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 I'm not sure what should be, but parts of it are incorrect.

On a test that utilizes this connectionstring to create a dummy database connection with Effort, I see the following error when I use it.

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'm not sure where I can locate this..csdl I just know it's necessary for the file. I can't make them from scratch.emdx I have a code-first database, and right-clicking in the designer does not provide the option to open a file, thereforeUpdate database from model like Yet another query suggested in his response. Moreover, I set the "Embed in Output Assembly" is the option for "Metadata Artifact Processing.".

Can somebody tell me where I can locate these files and how to properly reference them?

/Edit:

Okay, it is now crystal evident to me that the files are missing from coding first projects. The connection string appears to be working now after utilizing user20's tip, which is listed below in the comments. Here is a fresh problem:

`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 odd, given that I use[DataType(DataType.DateTime)] everywhere. Does anyone have a solution for this?

1
7
5/23/2017 11:53:43 AM

Accepted Answer

As user3038092 pointed out

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

It fixes the issue.

2
5/23/2017 12:08:41 PM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow