I am a newbie in .Net Core,
I am always using .Net Framework to develop an application (Web App / Web API). I have develop my custom Framework and it already established. my custom framework use Entity Framework 6.0 (DB First) Now, I have assigned to develop Web Api in .Net Core. but still use my custom framework to process the data. on .net core web api I need to assign connection string like web api on .net standard In .Net Standard my Connection string like below
<connectionStrings>
<add name="CompanyEntities"
connectionString="metadata=res://*/CompanyModel.csdl|res://*/CompanyModel.ssdl|res://*/CompanyModel.msl;provider=System.Data.SqlClient;provider connection string="data source=127.0.0.10;initial catalog=XYZ;persist security info=True;user id=sa;password=zzzxxx123!;multipleactiveresultsets=True;application name=EntityFramework""
providerName="System.Data.EntityClient"/>
for application using .Net Standard Framework (WebApp/ WebApi)... there is no Issue with this. it runs normally
but I don't know, how I can set connection string on .Net Core? please help
I have tried connection string like this but failed
"ConnectionStrings": {
"CompanyEntities": "Data Source=127.0.0.10;Database=xyz;uid=sa;pwd=zzzxxx123!;MultipleActiveResultSets=true;Integrated Security=False"
}
this is the error :
Severity Code Description Project File Line Suppression State Error CS0311 The type 'Classes.Model.Data.Library.CompanyEntities' cannot be used as type parameter 'TContext' in the generic type or method 'EntityFrameworkServiceCollectionExtensions.AddDbContext(IServiceCollection, Action, ServiceLifetime, ServiceLifetime)'. There is no implicit reference conversion from 'Clasess.Model.Data.Library.CompanyEntities' to 'Microsoft.EntityFrameworkCore.DbContext'.
and this my dbcontext
public partial class CompanyEntities : DbContext
{
public CompanyEntities()
: base("name=CompanyEntities")
{
}
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
throw new UnintentionalCodeFirstException();
}