I'm creating asp.net core web application and there'is no database templates in new item window. I've installed "Data storing and processing", "Entity framework 6 tools". I'm actually want to create ADO.net template, but it seems to be I need to install something for any database templates to appeared
ADO.net template is removed in Asp.Net core.And NET Framework, as Entity Framework 6 doesn't support . NET Core.So you should use Entity Framework Core rather than Entity framework in Asp.net core.
If you want to use Entity Framework Core with an Existing Database in Asp.net core,you can refer to the official tutorial.
That looks like normal behavior. In .NET Core you'll need to use Entity Framework Core. If you're trying to reference an existing database, you'll need to scaffold it as they've done away with EDMX models in EF Core. Here's how:
If you don't have it already, install the Microsoft.EntityFrameworkCore.Tools NuGet package and any other EF Core packages you think you might need. For example, if you're developing against SQL Server, install the Microsoft.EntityFrameworkCore.SqlServer package.
Run the scaffolding command in the VS Package Manager Console for the database you're trying to add. Something like the following, although you'll want to read the documentation first to determine the parameters you need:
Scaffold-DbContext 'Data Source=(local);Database=MyDB;Trusted_Connection=True' Microsoft.EntityFrameworkCore.SqlServer
This will create a context class for your database that you can then reference throughout your project.
Related
I am trying to build a .NET Core application. For this purpose I create a new MVC project from the template ASP.NET Core Web Application (.NET Core).
Once I do this, I inevitably need to install some NuGet packages, and see that there are 26 updates available for my project. So I hit "update all" and get into a big mess. One was having to manually edit the project.json to make the .NETCore.App an object with {"version":"2.0.0","type":"platform"}. Now in the project.json most of the stuff is at version 2.0.0 but I get all these error messages in the Error List, and all of them say pretty much the same thing: The dependency Microsoft.AspNetCore.Authentication.Cookies 2.0.0 does not support framework .NETCoreApp,Version=v1.0
What is my missing step?
Answer came in form of comment:
VS2015 is no longer supported for .Net Core projects. You need to upgrade and migrate your project.json to .csproj too. – DavidG
I've just created a new ASP.NET Core API and I have a legacy EF project with a few migrations. I referenced it to the API project. Initially everything seemed fine (the project builds without errors and I can run it).
Now I want to add a new migration. I've tried to do it an old way using my EF project as a -ProjectName parameter but it didn't work.
Is it possible to use legacy EF project with ASP.NET Core and if yes how can I work with migrations now?
I am using Visual Studio 2010 with MVC 4 installed along with Entity Framework 4. Is there any development tools to generate repository and uow classes for EF4? There is an EF4 DBContext generator, but did not see anything else for the dated EF4.
There is a NuGet package I created:
https://www.nuget.org/packages/RepositoryGenerator/
This is targeted to EF6 but it should give you a good starting point, it's a lot easier to change a few statements for EF4 compatibility then to create one from scratch. I'm also working on supporting EF4 in the future.
Times have changed--now we have Visual Studio 2012, MVC 4, Nuget--and it seems like the procedures in the Hanselman blog and the more recent Channel 9 tutorial could be enhanced. Both Hanselman and Kane recommend using DIFF tools to merge MVC functionality into the Web Forms Project (to endow the webform's .csproj and web.config etc with MVC). However now that Nuget manages packages, I wonder if it would be easier to merely install MVC 4 into the Web Forms project using Nuget; while of course following the procedures in the blog and the channel 9 demo for incrementally upgrading the Webforms project, including dealing with aspx login controls that postback, ascx user controls, and changing base classes Page to ViewPage and MasterPage to ViewMasterPage.
Has anyone tried to use Nuget to endow a Webforms project with MVC 4, and if so, would you recommend that technique?
UPDATE
I am following the Kane method which is an ordered set of guidelines (like modifying a complicated recipe in cooking) and am using NuGet to avoid some tedium. The guideline requires you make a dummy MVC project and compare it to your ASP.NET project to see what you need to add to your original project. You can add stuff using NuGet GUI, but that gets you latest stable assemblies versions which may lead to the dark insane demon of incompatibility. Instead use the NuGet console command line to get the compatible versions listed in the dummy MVC project's packages.config as explained in the following: How to install an older version of package via NuGet?
I installed MVC 4 when it was in beta, so I didn't get the SimpleMembership library back then. Now I've built a large project using the old MembershipProvider and was wondering how to upgrade from that to WebMatrix SimpleMembership.
I've already created the database schema and EF model and mapping classes. Now I'm wondering how I can upgrade the rest (install required libraries, etc.)
Is there some upgrade path I can follow, just to bypass screwing up my project?
Here is the upgrade path I used:
Backup everything (Code and SQL)
Create a new Internet Application [with SimpleMembership]
Move following folders from old project to new project:
Scripts
Content
Images
Controllers [don't overwrite AccountController]
Models [don't overwrite AccountModels]
Views
Insert connectionString from old project into Web.config
Run project and create a new user. Then the SimpleMembership SQL tables will be created automatically.
Use Entity Framework Power Tools, right click on project and choose Entity Framework -> Reverse Engineer Code First, to generate all EF entity/mapping classes for all SQL tables.
Delete UserProfile entity and UserProfileMap classes, because they come with SimpleMembership's AccountModels.
Refactor GUID to integer in all project.