MVC 3 web being built in VS2012 Update 1, connected to MySQL db.
I added an ado.net entity model as usual and all was fine until I realized the auto generated classes were not updating despite this bug supposedly being fixed in the VS Update 1. Anyway, I ended up deleting all the entity files (.context.tt, .designer.cs, .tt & the ed,x.diagram) I also deleted the ' connection string from the webconfig.
I then started over, added a new ado.net entity model, etc, but it keeps trying to add a 1 to the end of the name (same as the last one), so i assume there is still some reference to the old entity model in there somewhere.
Where are all the references,s o I can delete them? Is there a better way around this? I guess I could just choose a completely different name for the entity model, but that seems cheesey.
Oh and one other thing, I grabbed EF 5.0 with nuget, but in the project references, and all through the web config, it is referencing ef 4.4. Could this be part of the issue?
Normally, version 4.4 of EF will be referenced if you only have .NET 4 and not .NET 4.5.. check your project properties and see what version you are targeting
As for the connection string with a "1" on the end.. this may be a dumb question, but have you tried to find any references the old connection string by using "Find" and searching entire solution?
Related
I have been working on an ASP.NET MVC Core 2.0 project (targeting .NET Core 2.0) that needs to make use of Entity Framework. The database to be used already exists and I can't change it. I have added all the required references to Entity Framework Core 2.0.
However, when I run the following scaffolding command from the Nuget Package Manager Console, I get POCO model classes for the tables with different capitalization as compared to the original tables. In addition to other differences, columns with underlines in their names are represented by properties without the underlines.
How can I force the scaffolding to leave all table and column names as is when the POCO model classes are generated?
Example of scaffold command:
Scaffold-DbContext "Server= Info;Database=Vehicles;Trusted_Connection=True;" Microsoft.EntityFrameworkCore.SqlServer -OutputDir Models –force
The -UseDatabaseNames option is intended to preserve the names exactly as they are in the database (with only minor corrections if they aren't valid C# identifiers).
Unfortunately, this option got left off the Scaffold-DbContext command in version 2.0 (issue #9146) and it wasn't applied to property names (issue #9820). You'll have to wait for EF Core 2.1 to use it as it was intended. If you're eager to try it sooner, you can always use the nightly builds.
Solution: You have to update to .Net Core 2.1+, then you can run Scaffold-DbContext -UseDatabaseNames. I have tried this in Net 2.1 RC, it's working now.
I am planning to upgrade MVC3 EF5 project to MVC6. I understand it will require a lot of manual changes all over in config files, project files, entity framework, etc. Before I spend hours, wanted to see what is the best way?
Option 1: to make changes in IDs, configures, assemblies, etc. in the existing project (it doesn't even open in VS2015 right now, like any other MVC3 project, Thank You Microsoft). Looking at the instructions for converting MVC3 to MVC4/5, I guess I will need to have an ambulance on the standby here :-) It amazes me that MS did not provide any tool or even clear instructions to help developers.
Option 2: Create a brand new project in VS2015, then add new controllers with the same name as found in the old projects, then copy and paste controller implementations. Views and non-controller classes should work without much changes (only change I can think of is that new versions of dependencies in imports may be incompatible and will need to be dealt with manually, but this would be the same in Option 1). Not sure how to deal with entity framework. Perhaps if I recreate the entity model from database again, it should generate a compatible code. But then there are probably about 100 stored procedure function imports. I guess I will need to create function imports manually one by one (Question here, will the existing function imports remain intact if Option 1 is followed? Is there a way to copy function imports from the old project?).
Sorry, I know this is a rather convoluted question. Just trying to solicit inputs from others who may have done this in the past. I understand both Option 1 and 2 will require hours of work.
I stumbled upon an issue after following the steps described in http://documentation.telerik.com/openaccess-orm/quick-start-scenarios/getting-started-root-quickstart-vs-light-switch-wcf-ria . I can generate the Model and the Service just fine and adding the DataSource to the Lightswitch project also proceeds without a problem.
If I afterwards create a Desktop client with a screen based on the OpenAccess Service, I can filter and view the data properly, but any attempt at editing or deleting existing records results in an error message stating "Specified entity is not managed by a context". Adding new records works alright (and the newly added records exhibit the same symptoms).
I'm working in Visual Studio 2013 and followed the steps from the Quick Start guide. Is there something I'm missing here? Did anybody succeed at getting a LightSwitch-editable Service from OpenAccess or is it some sort of a known issue that's not stated anywhere explicitly?
I posted the same question on the Telerik Forum and they admitted that they could reproduce this error but could not find any workaround at the moment. They added the issue to their Lighswitch integration roadmap but the timeframe for the fix is yet unknown.
I solved the problem replacing Telerik OpencAccess ORM with classic WCF RIA Service solution (according to the tutorial: http://www.c-sharpcorner.com/UploadFile/raj1979/how-to-use-wcf-ria-service-in-lightswitch-2012/ ). I also had to switch to Visual Studio 2012 to be able to create a Domain Service Class.
Summing up, I had to change some tools but everything works perfectly now.
I've rebuilt my entity framework in an MVC 3 project. This was working before I did this. Now though, I get the error:
The type or namespace name 'myEntities' could not be found (are you missing a using directive or an assembly reference?)
everywhere in my code where it references the Entity Framework. This was working before the rebuild so it follows that it has to be that. I've checked that the name of the connection in my web.config and have deleted and re-installed the entity framework but it's not being referenced.
Any ideas how to fix this error?
Today I faced the same issue and waste my entire day.
Finally I start reading errors line by line and found the exact error.
On two tables I removed relationship and that was all the cause of problem.
Even I added all the relationship and update model but still not working.
Removed those tables from emdx on which I removed and re-added relationship
rebuild and found everything gone except the removed tables
Added those tables and done
Lo and behold, it was simple. I named the connection string to a different name than the object name I call in my code!
I solved this problem by deleting all tables from Entity .edmx then right click and select update model from database and select all tables you want ,Next rebuild the project.
Why don't you check out this other SO post which has a very similar problem to yours. It gives a few different suggestions to fix your problem and hopefully one of them will work out for you! Cheers!
The referenced component 'EntityFramework' could not be found.
Today I updated one table column. Had to delete and then re-add the table and any tables with a relationship to it to get it to generate properly again.
you can make another connection string...
or
try mentioning Using system.data.entity,
or
intall entity framework using manage Nuget Packages
or
select project name-> click tools(from menu items)-> package manager(nuget)->terminal
paste and run=> install-package EntityFramework
or
Find entity name in model browser as for example(green name in red circle)
Is there any open source projects or demo projects using Linq2Sql as primary data layer for accessing and updating all its data?
I am working in a project(asp.net webapp) which has Linq2Sql in DAL. We realized that half way through the project our design is not properly working out. I would like to see how Linq2Sql is being implemented in multilayered project. Any reference or guidance would would be good to.
I am already aware that Entity Framework is preferred way going forward but this project is mostly done in Linq2Sql, so we would like to finish it out.
a year ago, when I tried asp.net MVC I used nerd dinner to learn it, if I remember correctly, it's using linq2sql