Closed IsaaasI closed 2 years ago
It sounds like you may need to add an implementation of IDbContextFactory
to your assembly. In version 2.0.0-preview1-final, we temporarily stopped using the ASP.NET Core application service provider to discover the DbContext. Have you considered upgrading to version 2.0.1?
Many Thanks bricelam for your fast replay. I updeted the package to v2.0.1 and I face the below issue. Actually, If possible to contact with you on Skype and I will share my screen with you to solve the problem faster .
Installed Packages & SDK
@IsaaasI Remove the Microsoft.EntityFrameworkCore.SqlServer.Design dependency, it is not used in version 2.0.
Also remove the Entity Framework 6.2 from your project!
Entity Framework 6 does not support .NET Core
Also upgrade Microsoft.AspNetCore.All
to 2.0.3 version.
@bricelam Still same issue. required your help. @ralmsdeveloper I deleted both Microsoft.EntityFrameworkCore.SqlServer.Design & Entity Framework 6.2 and still I have below issue.
@smitpatel I tried many times to update to 2.0.3 but no luck . below the issue. I already cleared the cache for NuGet and same thing.
@IsaaasI, Do this manually, edit your * .csproj file.
Search for:
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.0-preview1-final" />
and replaced by:
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.3" />
Also do this for System.Text.Encodings.Web, the stable version is 4.4.0.
@ralmsdeveloper I am not able to find the .csproj from the Solution Explorer. I think the structure for VS 2017 and .NET core 2.0 application is different than previous version.
I open it from Window explorer by notepad I found these statements.
Check this file.
Yes , True
I fix it but still the migration not work :)
Can I chat with you on any chatting application to solve migration issue? I want only connect .NET Core2.0 app with MYSQL Database by entity framework .
@ralmsdeveloper @bricelam
Are you installing the Microsoft.EntityFramework.SqlServer package and want to try connecting to MySQL?
You will not, wrong package!
Try using MySql.Data.EntityFrameworkCore.
You may need to update Program.cs too.
It is already installed , are you sure the Entity Framework 6.2 not required ? Brcasue the below error is I think required Entity framwork. No DbContext was found in assembly '***'. Ensure that you're using the correct assembly and that the type is neither abstract nor generic.
I delete SqlServer @ralmsdeveloper
I will try update Program.cs now @bricelam
The program.cs is already updated.
@bricelam
Post your DbContext here.
This is my error now.
I think it would be ideal, you see some articles before, to help you better understand, how to use EF Core:
https://docs.microsoft.com/en-us/aspnet/core/tutorials/
https://docs.microsoft.com/en-us/aspnet/core/data/ef-mvc/crud
@IsaaasI - Your project has errors. Before running migrations make sure you can build you project in VS without errors.
Thanks a lot @ralmsdeveloper . Finally, I did it . The Migration work fine now. But :) 1.enable-migrations -> works fine. 2.Add-Migration -> works fine 3.update-database -> works fine
But I didn't see the table created on my localhost database.
This is my connection string. I am wondering about my schema name , username and password of my database where I put it?
Remark: I am using MySQL Workbenck 6.3 CE
@smitpatel Yes, It seem like that . The issue is solved and migration work fine but remaining above issue.
Its Context is configured to use SQL Server and not MYSQL, so it is impossible to see the tables!
It would be very important to study the documentation!
https://docs.microsoft.com/en-us/ef/core/
or some article that shows how to use Asp.Net Core + EF Core
It looks like you're a little confused :)
I'm sure you can do that.
It would be important for you to search for articles on the internet, there are several good blogs for studies!
one of them is: https://channel9.msdn.com/
The EF team is wonderful, they are super attentive, they always try to respond in the best possible way.
But your case is a bit quirky, because here they usually discuss improvements or bugs in EF.
@ajcvickers
Dears, I am using VS2017 .NET Core 2.0 and I want to use entity framework MYSQL Database but I am facing issues on add-Migration
No DbContext was found in assembly 'ProjectName'. Ensure that you're using the correct assembly and that the type is neither abstract nor generic.
Microsoft.AspNetCore.All 2.0.0-preview1-final
any help @bricelam