ConnectionString Builder in Entity Framework Core 2

c# entity-framework-core

Question

I'm trying to convert an old project c# to asp net core and to the EF core 2.0 and I can't find the EntityConnectionStringBuilder.

public string GetEntityConnectionString(string databaseName, string metadata)
{
    string providerName = "System.Data.SqlClient";
    string providerString = GetConnectionString(databaseName);


    System.Data.Entity.Core.EntityClient.EntityConnectionStringBuilder entityBuilder =
    new System.Data.Entity.Core.EntityClient.EntityConnectionStringBuilder();

Error CS0234 The type or namespace name 'Entity' does not exist in the namespace 'System.Data' (are you missing an assembly reference?)

1
2
3/13/2018 5:19:40 PM

Accepted Answer

That's because EF Core does not support what was known "database first" approach of older EF versions, so there are no edmx files, and so there is no use for EF specific connection strings (metadata=res:... < this kind of connection strings). From that it follows that there is no use for EntityConnectionStringBuilder class, which is used to create such connection strings.

So when porting, just remove your whole GetEntityConnectionString method and use your GetConnectionString instead, together with UseSqlServer, UsePgsql and similar methods.

1
2/21/2018 11:53:23 AM


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