Search code examples
c#entity-frameworkentity-framework-6fluent-entity-framework

Why doesn’t MS EF v6 Fluent API use EntityClient?


I am new to the Entity Framework, and have just gotten through Lerman’s EF book. Unfortunately, it only covers EF v4. I am looking at the Fluent API in EF v6, and it seems much better and easier to use.

Unfortunately, Fluent API in EF v6 seems to be using SqlClient instead of EntityClient – at least from the connection string (provider name). Why is that? Does this mean we would not be able to use it with Oracle or any other non-MS DB?


Solution

  • EntityClient in EF4 (and in fact in EF5 and EF6) is a way of boxing database related concepts and EF related concepts. Database related concepts is how EF is talking to the database while EF related concepts is how the model looks like. In EF4 the model primary means for serializing the model was the edmx file which contained CSDL, MSL and SSDL artifacts. If you look at the entity connection string it consists of paths to the artifacts (i.e. CSDL, MSL, and SSDL) which are EF related concepts and a provider connection string which is the database part. In fact for Model and Database First even EF6 still works the same way. For Code First approach your code (along with the configuration in the OnModelCreating and custom conventions) is your model. As a result there is no need to serialize and store your model because it is part of your app. Therefore the EF related concepts could be dropped and after doing so, only database related concepts remained which were already captured in the ADO.NET provider model.