Difference between EF.SqlServer and EF.SqlServerCompact - asp.net

I want to install Entity Framework in my ASP.NET 5 MVC project using project.json.
In the dependencies section I start typing EntityFramework and I only see
"EntityFramework.SqlServerCompact": "6.1.3" instead of "EntityFramework.SqlServer": "6.1.3".
What is the reason for this and what effects will this have?
Are there limitations in the compact version?
If I create a new ASP.NET 4 project with MVC and install EntityFramework then I see the EntityFramework.SqlServer reference installed and not the compact.

EntityFramework.SqlServerCompact is for interacting with SQL CE. It's a single file based database. If you're dealing with MS SQL Server, that's definitely not what you want. You want EntityFramwork 6.1.3, there is no EntityFramework.SqlServer.

Related

ASP.NET 4 - How to generate asp.net identity schema for database in SQL?

I am using VS2019 16.10 to create an ASP.NET 4 application (.Net 4.7.2 - not MVC) and have set the option to use local authentication. After generating the application it has not created the schema for the asproles, aspusers etc. tables in the database.
I have enabled migrations but all that got created is an empty seed() function in the migrations directory.
The NuGet package that was installed is Microsoft.AspNet.Identity.EntityFramework v2.2.3
Does anyone have a link to a SQL script that creates the schema?
I have tried a couple but get errors with missing columns.
Regards.
Well, assuming you are running sql server x64, which is likely?
Then this path should work:
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet_regsql.exe
The solution that I found the closest to work was to create a basic asp.net 2.1 project in Visual Studio which generated the migration. I was then able to use the Package Console Manager to generate the database schema that could be run in SSMS.
The only issue was a missing column in the AspNetUsers table LockoutEndDateUtc which I added manually.

How to properly change target framework to .NET 4.0

I built an application with target framework .NET 4.6 using MVC 5 and Entity Framework 6 using Visual Studio 2017 on my Windows 7 machine. I'm now being told that I should have built the application to target .NET 4.0 because the production environment only has 4.0 installed. So I changed the target framework to 4.0 but now the application will not build on my machine.
I'm guessing I also need to downgrade MVC and EF. How is the proper way of doing this?
And which versions of MVC and EF should I install?
Do I need to make any manual changes to web.config?
There is no "proper" way, you have 3 options, in my favorite order:
Update the server and install the latest .net version. (at the time .net 4.6). Make sure used libraries are up to date and not end of life.
Start over in a new project and make sure you target version 4.0: you can copy most of your source files. You'll probably get some compiler errors, but usually they are easily fixed. This way you'll have the benefit that the used template matches the framework and packages version(s).
Re-target the used framework in the project properties and replace the packages which are installed and hope for the best (sometimes you need other packages). Hopefully you used the package manager to install those packages. Maybe the update-packages command helps, but be sure to backup your project first. Some packages become obsolete after time, some are renamed. This is what will cause issues. Also, some of the Methods/API calls will be different, so some rework will be needed.
As for the rest of your questions:
I'm guessing I also need to downgrade MVC and EF. How is the proper way of doing this?
Use the nuget package manager
And which versions of MVC and EF should I install?
The nuget package manager will fix this for you.
Do I need to make any manual changes to web.config?
Sometimes: yes.

Asp.net 5 mvc 6 Entity Framework 7 database first

I noticed that this type of project does not support files edmx.
What is the right way to develop a project in Asp.net 5 MVC 6 using Entity Framwork 7?
Currently(as of EF 7, RC1) Database First support is still in development. More info on roadmap page here and on EF Design meeting notes here.
Since this is in development there are ways to try this and more info and tutorial on commands can be found at official documentation page here.
The problem is that EF7 kill EDMX. You now have Code First-style POCOs tied to an existing database, without an EDMX file in sight. The EF Power Tools Visual Studio extension can be installed to generate all of this directly from existing database.EF Power Tools Visual Studio extension actually doesn't support vs 2015

ADO.NET Entity Data Model missing Visual Studio 2015 community

I am starting a new ASP.NET 5 Preview template to play with client side development.
I have a database ( MS SQL ) that I want to access using the Web API and Entity Framework.
In my Models folder I do like I am used to do, add a new item and I want to add the ADO.NET Entity Data Model but it isn't there.
What am I missing here?
UPDATE
This is the only thing I see when I try to add a new item to the project.
Client side and server side.
After a lot of research, I found out that there are some compatibility issues where come from the recent Microsoft migration to open source world (since Asp.net5) that I obtained from Data Points - The EF6, EF7 and ASP.NET 5 Soup MSDN Article. Read the full article please.
So if you wanna have both EF6 and Asp.net5, consider the article tips. And if you don't persist in using Asp.net5, simply use Asp.net4.5 (following image) which have Ado.net Data Model in Add New Item dialog (I tested its availability with my Visual Studio Enterprise).
May sound stupid, but since I got caught with this, it might be someone else's issue too...
In VS 2015, there are 2 project templates called Class Library... one being in Windows and one in the Web and having (package) suffix. Apparently, besides misleading name they have nothing to do with each other and the second one clearly is not made to support EF models... Make sure you have created a proper project type or open a working solution made with different VS version.
__
Also this might help. I have it already installed, so not sure if it affects my configuration or not (shouldnt as EF tools are supposed to be shipped already with VS 2015):
http://thedatafarm.com/data-access/installing-ef-power-tools-into-vs2015/
Right click on project
Choose Add and then New Item (or Simply press Ctrl+Shift+A)
You will see a Data section which you can find what you are looking for
Or You can find another solution Here:
Missing ADO.NET entity data model template from visual studio 2012 professional
Create New MVC Project using VS2015
Right-Click on Model folder.
Choose Add and then Select Class from the list.
Now select ADO.Net Entity Data Model... and go for your selection.
ADO.NET Entity Data Model missing Visual Studio 2017 Community
How to enable:
Open Visual Studio Installer -> Individual Components -> SDK's, libraries, and frameworks -> Enable EntityFramework 6 tools-> Modify
Now, Add item in your project -> Data -> ADO.NET Entity Data Model.
Visual Studio Installer
Note: While Creating project don't select class Library(.NET Standard) Choose Class Library (.NET Framework)
I solved the same problem by following these:
While Creating project don't select class Library(.NET Standard)
Choose Class Library (.NET Framework)
Choose ASP.NET Web Application (.NET Framework)
Go to Tools -> Get Tools and features. Select Individual components tab and check Entity Framework 6 tools under SDK's, libraries, and framework section
Remember you can't make an ADO.net Entity Data Model with an interface with .NET Core, its only possible with .NET Framework.

ASP.NET vnext and open database

is there some possibility to work with an open database like mysql, mariadb or other and ASP.NET vNext?
Perhaps a beta driver or something like that?
For ASP.NET vNext you can choose to target the full .NET Framework or a slimmed down, bin-deployable, cross platform, Core framework.
If you target the full .NET Framework then you get all the data access options you had before. If you target the CoreCLR then you can use the new version of Entity Framework (EF7). Currently we have the following providers available on CoreCLR; SQL Server, SQLite, and an in memory provider for testing. Of course, more providers will become available as we work towards RTM.
In addition to EF7, there are also the corresponding provider specific SDKs that EF is building on top of, and these can be used in application code as well (e.g. there is an implementation of SqlClient that can be used to access a SQL Server database).
You can read more about our plans for EF7 here - http://blogs.msdn.com/b/adonet/archive/2014/05/19/ef7-new-platforms-new-data-stores.aspx.
It depends on if you are using the CoreCLR (the trimmed down version) or the Desktop profiles. In the Desktop profile you have everything you have in .NET available and you can add your own open source libraries (via Nuget).
Just open up your project.json and add the needed dependencies.
Anyway you should not be dealing with low level ADO.NET, you can use Entity Framework, or Massive or nHibernate, or whatever, to abstract away the specific database your project is using now, as it is bound to change or multiply during the project lifetime...
You should still be able to use anything ADO.Net related with ASP.Net vNext - it is, after all, still .Net!
Yes, it is possible, but only if you use full .net profile (on windows it will be .net framework and on linux - mono). NHibernate working well on mono, so you can eventually use mysql, postgresql and other databases in you APS.NET 5 vNext application. Here is complete example of application with NHibernate and PostgreSQL on Ubuntu server.

Resources