我正在为我们的一位客户排除 WPF C# 应用程序的故障。
该应用程序连接到 MySQL 数据库。但是,连接字符串采用“元数据”形式,带有 .ssdl 和 .msl 文件
这个元数据是什么,ssdl 和 msl 文件?
<add name="NFMEntity" connectionString="metadata=res://*/TrendData.csdl|res://*/TrendData.ssdl|res://*/TrendData.msl;provider=MySql.Data.MySqlClient;provider connection string="server=127.0.0.1;user id=mmm;password=mmmmmm;persistsecurityinfo=True;database=nfm"" providerName="System.Data.EntityClient" />
最佳答案
EF 使用包含 .csdl、.ssdl 和 .msl 的元数据部分,它们包含您通过 EF 描述的模型的不同层。此部分不是数据库连接字符串的一部分。
Exploring how the Entity Data Model (EDM) Generates Code and Executes Queries – Entity Framework 4.0博客文章提供了这些层的高级描述:
We know that Entity Framework maps database tables to objects. This is done in 3 different layers:
Logical Layer: The Logical Layer also called Storage Layer is defined by the Store Schema Definition Language (SSDL) and defines the structure of the tables and relations between them.
Conceptual Layer: The Conceptual Layer is defined by the Conceptual Schema Definition Language (CSDL) and defined .NET classes.
Mapping Layer: The Mapping Layer is defined by Mapping Specification Language (MSL) and connects the entity type definition from the CSDL to the metadata defined in the SSDL, hence the name C-S mapping. So the mapping is essentially from .NET classes to the table structure and its relations.
At runtime, this .edmx is split into these three different files (.ssdl, .csdl and .msl).
关于c# - 无法理解此 MySQL 连接字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39029818/