Upgrading .NET Framework 4.5 to 4.6.1 causes errors in Entity Framework classes - asp.net

IDE :: VS.NET 2015
Version Upgrade :: 4.5 To 4.6.1
My asp.net solution contains more than 30 projects inside. I have upgraded the targeted framework to 4.6.1 and now i am getting these tons of error in EF classes. The existing EF version is 6.0.
Please suggest how to fix these errors cropped up from the EF classes. Should i upgrade the EF version also from the Nuget console also.

If you have any models created with the EF Designer, you will need to update the code generation templates to generate EF6 compatible code.
Delete existing code-generation templates. These files will typically be named .tt and .Context.tt and be nested under your edmx file in Solution Explorer. You can select the templates in Solution Explorer and press the Del key to delete them.
Note: In Web Site projects the templates will not be nested under your edmx file, but listed alongside it in Solution Explorer.
Note: In VB.NET projects you will need to enable 'Show All Files' to be able to see the nested template files.
Add the appropriate EF 6.x code generation template. Open your model in the EF Designer, right-click on the design surface and select Add Code Generation Item...
If you are using the DbContext API (recommended) then EF 6.x DbContext Generator will be available under the Data tab.
Note: If you are using Visual Studio 2012, you will need to install the EF 6 Tools to have this template. See Get Entity Framework for details.
If you are using the ObjectContext API then you will need to select the Online tab and search for EF 6.x EntityObject Generator.
If you applied any customizations to the code generation templates you will need to re-apply them to the updated templates.

Related

Outlook Interop in .NET Core 3.0?

I migrated our project from .NET Framework to .NET Core 3.0 (C#, WPF) and now I can not use Microsoft.Office.Interop.Outlook anymore, because it is not compatible with .NET Core 3.0. What I want to achieve is opening/sending prefilled Outlook Emails.
Is there an alternative to this interop dll, or maybe a way to use .NET Framework for only this reference?
Microsoft.Office.Interop.Outlook
NetOffice.Outlook
This worked for me:
Right click Dependencies and click "Add Reference"
Select Microsoft Outlook 16.0 Object Library under the COM tab.
Under Dependencies/COM in your project, select Interop.Microsoft.Office.Interop.Outlook reference, then under "Properties" set "Embed Interop Types" to "Yes"
I also had to uninstall the Microsoft.Office.Interop.Outlook NuGet package because it caused a conflict with the reference in Dependencies/COM.
Outlook automation is now working fine.
I am having the same issue when trying to use Microsoft.Office.Interop.Excel 15.0.4795.1000. It won't run when I target .net core 3.00 preview 7.
At this stage I do not think there is any other option than reverting back to .NEW Core 2.2.
I had the same problem while migrating components with Office interop for Excel and Outlook to .NET Core 3.0. I found out that this is only a problem of the Nuget packages Microsoft.Office.Interop.Outlook and Microsoft.Office.Interop.Excel. The packages probably need an update to work with 3.0?
If I make direct references to the Interop assemblies all is working well. Here is a link to an example for this.
If you use Visual Studio, you need an additional workaround to achieve this. From the linked sample:
Adding COM references to .NET Core projects from Visual Studio is not
currently supported. The workaround is to create a .NET Framework
project, add the COM references, and then copy the relevant
COMReference elements in the project.
This is possible in a roundabout way. Here is how:
Create a temporary .NET framework project.
Add the references to COM components (Microsoft.Outlook.Interop).
Open that csproj file and copy the entire those components are located in, over to your .NET Core project.
The nuget packages seem to be incompatible at the moment.
Reference: DotNet Samples

How to create custom scaffold templates which are not using entity framework entities directly in ASP.NET MVC5?

I'm using VS 2015 with EF 6.1.3. with MVC5.
I know that MVC5 scaffolding templates are located in
C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\Microsoft\Web\Mvc\Scaffolding\Templates\
But I cant use them since standard scaffolding is not an option for me.
I would like to generate similar views and controllers against my custom POCO classes eg. ViewModels that are located in BL.
Can you run and customize those (or some other) templates so that they could generate MVC controllers and views from some other classes or repository?
Here's a good general article for custom scaffold templates in MVC
https://www.credera.com
http://www.c-sharpcorner.com
https://www.youtube.com/watch?v=YIr18d5wBXM
May be it's helpful for you.
If you are already use to T4 template syntax you can try out my extension T4 Awesome. It adds a lot of UI to visual studio for running templates and supports parameters, one of which is a code type that allows you to use POCO class metadata inside your templates. This would allow you to generate views and controller stubs much like scaffolding does but in a very quick way. In scaffolding you have to build/test/compile/deploy your scaffolds, its almost like working on another project altogether. With T4 Awesome, all you do is create your templates and use them, edit as needed, and this all happens within the same solution as your code. Full disclaimer, there is a charge for using the advanced features but I do have a community edition that will do what you want and is free for forever.

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.

How do I create a ASP.NET project based on the .NET Core, not on the full Framework?

I was reading all about .NET Core after hearing about it for months. I got Visual Studio 2015, so I thought I would try it out. I go into File - New Project, choose ASP.NET Web Application, and see I can only choose a version of the full .NET Framework (such as 4.6). How do I create a ASP.NET project based on the .NET Core, not on the full Framework?
I thought there would be some tutorials on this, but I can't find any. All I see is based on the full Framework.
ASP.NET 5.0 Core beta5 shipped with VS 2015 RTM. Beta6 just shipped and be used to upgrade VS 2015. (Read the Install Instructions!)
When you create a project from one of the ASP.NET 5 Preview Templates (Empty, Web API, or Web Application) it is set up to compile both Core and 4.5.1 Framework versions every time you build.
To change this to build only Core, do the following:
Project / Properties / Application: change Platform from .NET
Framework to .NET Core
Open project.json and find the "frameworks" section. Delete
"dnx451": {}, and save.
Build
You are now running on the CoreCLR.
You can find the .net core and nightly builds at:
https://github.com/dotnet/core
https://github.com/dotnet/coreclr
Thanks for the comments and whatnot guys... Can't delete my answer since it's accepted, so here's some screenshots showing how to get to the new template. Note that the new framework version is not listed where you (at least I) would expect. You can choose the asp.net 5 tempate after you actually choose to create a web application in one of the (non 5.0) framework templates.

Resources