Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 655
Erwin Rooijakkers Avatar asked Dec 02 '13 14:12

Erwin Rooijakkers


People also ask

What are CSDL files?

Conceptual schema definition language (CSDL) is an XML-based language that describes the entities, relationships, and functions that make up a conceptual model of a data-driven application. This conceptual model can be used by the Entity Framework or WCF Data Services.

How do I get a CSDL?

You can obtain the CSDL for a model by sending a DISCOVER request to the server that hosts the model. The request must be qualified by specifying the server and the model, and, optionally, a view or perspective.

Can you explain CSDL SSDL and MSL sections in an EDMX file?

CSDL (Conceptual Schema definition language) is the conceptual abstraction which is exposed to the application. SSDL (Storage schema definition language) defines the mapping with your RDBMS data structure. MSL ( Mapping Schema language ) connects the CSDL and SSDL. CSDL, SSDL and MSL are actually XML files.

What is MSL in C#?

Mapping specification language (MSL) is an XML-based language that describes the mapping between the conceptual model and storage model of an Entity Framework application. In an Entity Framework application, mapping metadata is loaded from an . msl file (written in MSL) at build time.


1 Answers

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.

like image 116
Erwin Rooijakkers Avatar answered Sep 22 '22 06:09

Erwin Rooijakkers