Unable to load the specified metadata resource still comes - asp.net

Yes, I know, this is the n'th question around this issue. I tried a lot of mentioned ~solutions, but none of them worked for me.
Windows 8.1, Visual Studio 2012, .NET 4.5.51641, Entity Framework 6.1.1
My struggle is to configure a well structured ASP.NET project, separate the different entities. I need more entities and in separate folders because of some overlaps among generated class names.
Therefore I've created a DAL folder and the first one, the Production. My model is quite simple, during the mode creation I've created the ProductionEntities entity connection string as it seems bellow:
Here is the ProductionModel.edmx and its properties:
I checked the assembly with reflector, all the resources are correct:
After that I've created a webpage and an EntityDataSource within it. If I select the ProductionEntities for Named Connection, I get above mentioned error message.
Have anybody some fresh idea for this? Thanks in advance!

I've got the solution!
After creating the entity model, it is MANDATORY to compile the project! After compilation the VS is going to recognize the entitydatasource wizard works fine...

Related

Simple database connection in ASP.NET?

I would like to make a very simple page that reads and displays data from a (SQL Server) database.
I've been messing with ASP.NET MVC, but for what I want (a quick solution in a single, simple webpage) this seems like overkill. Razor WebPages seems a better solution.
The database object from WebMatrix.Data seems good, but I cannot get this to work in Visual Studio Express 2013. I keep on getting "The type or namespace name 'WebMatrix' cound not be found", even though I added WebMatrix.Data to the References of the project.
I've also tried using Entity Framework (even though that also seems like overkill), but that comes with other cryptic errors like "A namespace cannot directly contain memebers such as fields or methods" (with the error message leading to a source file that only contains "ErrorGeneratingOutput").
I really can't understand why this needs to be so difficult? I just want to quickly output some records from a database onto a webpage, nothing fancy.
I found the solution; I had to install the "Microsoft ASP.NET Web Pages Web Data" package using nuget.
I have not found any documentation on this; the StackOverflow answer at https://stackoverflow.com/a/11870874/72809 was the only one that pointed me in the right direction. It's still very unclear to me when one has to use "Add Reference" and when one has to use nuget, but I'm happy this problem is solved for now...

MVC conversion project, fully qualified classes are not available unless 'Global' is added or System... is removed

My question is similar to here: ASP.NET System.Anything is not defined
I am in the process of converting a website project to an MVC 4 project. To do this, I created a new MVC project and imported all of my content from the previous website. Both projects are in VB, and I'm using Visual Studio 2010 SP1, with both the MVC 4 update and TFS 2012 update applied.
I now have errors popping up when I build the MVC project. Things like "Type 'System.Web.UI.Webcontrol' is not defined." When I hover over the error, two of the prompts I get to fix it are
1) Change 'System.Web.UI.WebControl' to 'Global.System.Web.UI.WebControl'
2) Change 'System.Web.UI.WebControl' to 'WebControl'
Both of these seem to fix it, but does anyone know why I can't use "System.Web.UI.WebControl" to refer to this class? I'd rather not change all of my code... there are 100s of thousands lines in there.
Update: Outside of the System and System.Web.UI namespaces, I can also drop the 'System.'. So 'System.Drawing.Color' would become 'Drawing.Color'.
There exists another namespace containing System in your solution somewhere (e.g. Abc.System.def) - probably in a referenced library. After the conversion, the project file probably imported the prefix to System in said namespace (e.g. Abc), so when you type in System, it resolves to Abc.System.
I posted this question before I had whittled down as much of the compile errors as possible.
It appears that after I had removed all the System. references from the previous App_Code classes, the real errors started appearing. There were all sorts of messages about aspx controls not existing.
Ultimately, it seemed that I needed to right-click on the .aspx pages from my website project and choose 'Convert to Web Application.' This generated a .aspx.designer.vb file with the asp.net control declarations in yet another partial class.
After doing that for all pages, I am now able to use System. throughout the app.
To others who've asked, this System. error was only affecting the non-page code. .aspx, .aspx.vb, .ascx, .ascx.vb, .ashx, etc., files were not affected.
This does make some sense, anyhow, as I had previously pulled in all the App_Code libraries prior to pulling in the pages, and the site compiled. After importing the pages and their code behinds, the order of the errors was just odd. But I stuck with it and found the underlying cause.
Thanks for the willingness to help. If you have any other questions, I'd be glad to respond.

Errors when including Entity Data Model across referenced projects

Decided to take a dive into recreating a website so that it's an ASP.NET MVC web application. We were originally using the Entity Framework for it, figured to still use it since it works nicely enough. When doing some reading, noticed the there is no such thing as the App_Code/ folder for MVC applications, and that most people were creating a class library for their needs like that. So what I ended up doing was creating my MVC application and a class library, both in the same solution, and the MVC application was referencing the class library. The class library has my EDMX Entity Data Model file in it since some of my classes reference it and I thought that it would be easiest to have it in the library to reference. So here is a picture to what my solution layout is. But when I build and run the website, I get an error on a page that would reference the Entity Data Model. Here is a picture of what the error is.
So I thought, what if I placed the EDMX into my models folder since the error looks like it's complaining about not finding the entities. Here's a picture of my solution now with the move. But now, I'm getting a different error (picture). I'm kind of at a loss as to where to go from here. Is the way I have everything laid out and designed the proper and most efficient way to do it? If not could someone give me some advice?
Thanks, it's really appreciated!
Yes, you should be able to have the edmx in a class library and reference if from your main project. The first error is likely due to an incorrect connection string (check this blog post) but you may also have changed the build action of the edmx file somehow, make sure it is "Entity Deploy".
The second error is probably because you copied the edmx from your class library into the Models folder and it is still referencing the old namespace. To fix that, open the edmx in designer view and click on the background. One of the properties in the property window is Namespace, make sure that's set to the new place you want to keep it.
Edit:
Some things to try:
Clean and rebuild the project
Delete the Temporary ASP.NET Files folder referenced in the error message
Double check your cshtml files for old references to URG_MVC.Models namespace. For example, the line in the error should be IEnumerable<URGLibrary.Proposal>
Right click the edmx file and select Run Custom Tool to regenerate the model files

How to find underlying source of this error? Designer/FormView/ObjectDataSource

In the designer I get this error: "Error Creating Control: Object Reference Not Set to an instance of an object". The page itself runs fine. One of the objects, possibly an objectdatasource has to be failing at design time. But how to find which one?
The project was originally designed with a XSD for the data pointing to SQL Server queries. All based on typical Microsoft demonstrations which don't really take the product lifecycle into account.
I have had to refactor a number of things in the database, and the XSD designer doesn't automatically show you what you need to fix, you just have to run and get a runtime error. Obviously this means that some of the many individual adaptor methods are probably still incorrect, and I'm going through and updating them to match the new database model, and then tracking through the effects through all the bound controls and everything. And eventually, I may get away from a lot of this wizard-generated code and have something a bit more able to be statically checked by the compiler during the build.
But for now, how do I find out which object reference is the problem?
Problem appears to be due to a null Context in code in a base class which worked fine in VS 2008 which was being called in design-time

Using nAnt to build projects containing EDMX

I've been working on training myself in the ways of using nAnt over the past few days, and have stumbled across an issue. During the development process, I've been using the new tools, like Entity Data Model, for database access.
When you go to try to build a library/executable that contains the Edmx product, you cannot embed the required files from visual studio. Now, I realize that I can do an exec task inside of nAnt and call msbuild for the particular project file, but I am trying to keep this to be completely nAnt build for now, so I'm in a heavy struggle to get things to work.
I did some searching to find a way ot handle this, and came across this Inline C# class that is supposed to do the trick. My problem is that I do not see how you call this in the target stack in order to get it to do its job. Can anyone shed some light on this? It would be of some great help.
Ok... so I'm a bit further along with this. I have since found that the code the gentleman has posted needs to be under the task for which it is meant to be run for. I'm even getting the *.ssdl, *.csdl, and *.msl files rendering into the directory... cool beans.
nwo i'm getting something interesting coming through... I've got reference via a "references" tag to System.Data.Entity, but I keep getting the following compile error:
error CS0234: The type or namespace name 'Objects' does not exist in the namespace 'System.Data' (are you missing an assembly reference?)
Any suggestions?
OK!!!
Got it! I had to edit the NAnt.exe.config file and add the System.Data.Entity.dll file into the Framework element for the .net framework 3.5!!!
I may wind up building a 3.5 SP1 entry, and if someone can give me a good area to post it, I'd be good to go.

Resources