MVC3 Code First, Cannot find Metadata - visual-studio-2010

I'm following a tutorial (http://weblogs.asp.net/scottgu/archive/2011/05/05/ef-code-first-and-data-scaffolding-with-the-asp-net-mvc-3-tools-update.aspx) to build a simple MVC 3 web application. I'm using a code first methodology and things were going good until I had to go back and add a field onto one of my models.
I got the error "Invalid column name 'Summary'." Which makes sense because this was the new field that I had added to the model.
Its my understanding that whenever Visual Studio realizes that the existing DB is different from the one that it is connected to, Visual Studio will try to recreate the DB. This is the behavior that I want so I added the following line to my Application_start in my global.asax file.
Database.SetInitializer<MyDBContext>(new DropCreateDatabaseIfModelChanges<MyDBContext>());
Now when I try to run the program I get the error "Model compatibility cannot be checked because the database does not contain model metadata. Model compatibility can only be checked for databases created using Code First or Code First Migrations."
I even deleted the existing database that I've been using so Visual Studio doesn't get confused.
What do I need to do in order to get Visual Studio to nuke the DB every time I change the models?

Related

Why does Visual Studio deploy two separate SSAS tabular models

So I've created a 2017 SSAS tabular model in VS. I've then deployed it to the SSAS tab work space server. But for some reason it creates two separate models. One normal and one with some random characters appended to it. Worse still, when I deploy changes to the model, it only updates the one with the characters appended.
What is going on here?
Deployment setting:
Two models showing in the work space server:
The tabular model with your username and a GUID is the workspace database. This is a local copy of the tabular model with the changes that you've applied to it when Integrated Workspace mode is not used. The workspace database is kept in memory while it's open in SSDT, and depending on the Workspace Retention property may be either removed from memory, removed from memory/disk, or still kept in memory. The default setting is to remove it from memory but not from disk, hence why you may not see this database whenever you close the model in SSDT. This property can by accessed from SSDT by highlighting the .bim file and viewing the properties (press F4).
The changes made to the workspace database should be applied to the deployed model when it's deployed using the model name as the target database on the deployment server, as in your screenshot. When you examine the model (non-workspace database) in SSMS, how do you know the changes are not applied to this, and have you tried refreshing the view from SSMS? This can be done by right-clocking the Database folder above the tabular models and pressing Refresh. Also, the deployment SSDT is succeeding without errors, correct?
Since I cannot comment on the correct answer I'll make it a separate answer.
What I saw happening was when you import a cube in Visual Studio (while creating a new project) a new tabular DB is created with the name "CubeName_username_Guid".
Everything you modify gets deployed to the real cube after you close Visual Studio. Also after you close VS, the oddly named cube also disappears.
I hope it helps.

Microsoft Office 14.0 access database engine ole db provider in visual studio 2015

This is my first attempt at writing a Visual Basic app using Visual Studio. I am using an Access 2013 database as the source and everything was going fine until I decided to add some calculated fields to one of the tables. Now VS is telling me that I need the "Microsoft Office 14.0 Access Database Engine OLE DB Provider" to read the tables.
I've been searching and searching but can't find anything about version 14.0 of the engine. Am I just missing something simple, or can I not access calculated fields in the DB and have to just pull the data and do the calculations in the app?
I am working on a machine with Win7 64bit, Office 2013 Pro, and Visual Studio 2015 Community.
Thanks!
EDIT: The calculated fields look like this:
"http://travellermap.com/api/jumpmap?sector="+Left([Sector],4)+"&hex="+[Hex]+"&style=print&jump=3"
Where [Sector] and [Hex] are fields in the same database. As soon as I added the fields to the database VS2015 would throw the error. If I tired use the Dataset Wizard it would tell me that there were fields in the database that were missing or could not be read without v14 of the engine.
Then even after I removed the calculated fields it still could not read the data. I have to revert to a backup copy of the database that never had calculated fields in it to get things back to working.
My exact steps were as follows:
Create database with multiple tables
Create a view that pulls together data from all the tables that I needed.
Create dataset in VS that uses that view which I called SystemMaster
Build app around it using the XAML designer
Decide that it would be quicker to use a calculated field int he DB than write the VB code to put together a URL that is needed to display an image in the app.
Close out VS2015 and laucnh Access 2013
Create the calculated field in the primary table and edit the SQL code for the view to include those fields
Save and close Access, go back into VS2015
View the dataset to see if the new fields are there, see that they are not and launch the Wizard only to find out that the Wizard says it can't access anything in that view anymore because fields are either missing or can't be read with the current version of the Access engine (12.0) and that I need version 14.0.
Search for answer, don't find one. Remove the fields from the tables and try to get back to a working application.
Realize that even after removing the fields, VS2015 won't read the tables ro views that had them.
Revert to a version of the database that did not have the calculated views, and everything works again.
While I know that the proper way to do this would be to construct the URLs in the VB code, this was easier and quicker (in theory) to do at this point which is basically a proof-of-concept/prototype.

Coded UI Test Builder fails to generate code

The coded ui test builder is failed to generate code. i created the new test project and added the coded ui test file. i have chosed the option 1.Record options then the Test builder is running.
when i record the actions and trying to generate code
it is throwing error
"Object reference not set to an instance of an object"
Kindly help in this.
There is no simple answer to this from the very small amount of information in your question. Searching the web for the error message (eg searching for "coded ui Object reference not set to an instance of an object" and variations) provides many cases of people getting the same message plus, in some cases, their solutions.
One possible cause is that the UI Map file has been edited in a text editor, leaving XML that the Generate tool does not understand. Another possibility is that Visual Studio has become corrupted and should be reinstalled.
To narrow down the possibilities, determine whether the problem is specific to one project, to one computer or to one user. Try creating a new Coded UI test in a new Visual Studio solution to drive a simple application (eg the Windows Calculator) and see whether the generator works OK. Copy the failing project (and the whole solution) to another computer and see whether code can be generated there. Try logging in as a different user on the same computer and generating code for the same project and for different projects.

Successful deployment from Visual Studio, but Sharepoint site shows old content

My company are working at Sharepoint site that we are developing using Visual Studio. The actual installation at the customer is performed by scripts deploying the produced wsp-files. During normal development I mostly use deployment from directly from inside Visual Studio. Unfortunately I often run into problems when trying to deploy my solutions. We are using a server-farm set up, but each developer has their own virtual server, datebase instance and so on.
We have one project file that the define the basic content-type used for different department. This content-type typically define stuff like what period that the list item cover. Each department have their own project that uses the content type combined with department specific fields to form the final list.
One of my current problems is that when I make edits to the content type and deploy it the changes does not seem to propagate. Even though I rebuild the solution and deploy both the base project and the department project with success I still see the old version of the content fields when I create a new department list. Sometimes it helps to retract the projects, but often I literally have to restart everything before it works.
My question is if this problem is caused by Visual Studio not really deploying my new defintions or if there is some architectual aspect of Sharepoint 2010 that might prevent the change to propagate. What steps can I take to lessen the likelihood of the problem occuring?
Have you tried deleting the content type with Central Administration before doing a new deployment? I've found out that Sharepoint don't update/create content types when it finds other one with the same name.

Entity Framework losing binding to connection string in Visual Studio

I'm having a problem where the Entity Framework edmx file is apparently losing its relationship to the connection string that it was built with.
The designer for my .edmx file was working perfectly - I could do "Update from database" and it would always jump to the wizard step that would allow me to add tables, procs, etc. Now when I click "Update from database", I get the "Choose your data connection" wizard step where it wants me to select a new database - if I go through these steps, it will create a new connection string for me, and regenerate all of the objects as if I was starting from scratch.
The contents of my app.config file are exactly as they were prior to the problem, but I did modify the file, then revert it back the way it was. I'm thinking somehow modifying this file triggers something that causes me to lose the binding, but I can't figure out what that is.
The connection string key in the config file matches the CdmEntityContainer attribute in the EDMX file.
I've even tried killing my codebase and re-checking-out from source control, but that doesn't seem to work. Other people working on the same codebase are having this same problem, so it seems that there's something definitely wrong somewhere in the project. But there were no relevant changes to the .csproj or .sln files - just nothing I can see anywhere that could be causing this.
Any ideas? The only solution I'm seeing right now is to delete and recreate the edmx files from scratch, but I'm definitely hoping to find something better.
EDIT: If I generate a brand new edmx in the project, unrelated to any of the existing ones, it seems to fix the rest. It must "reset" whatever is funky in the project. But this can't be a legitimate solution, so I'm still hoping for something better.
I just had this issue and in my connection string I was missing
application name=EntityFramework in the data Source
I just had this and solved it.
The problem was that the edmx was being used as my DAL, with its own project and web config, and the DAL was called by my ASP.NET project (the solution's default project) with ITS own web config.
The configs had been the same for ages, but the ASP.NET project was pointed to another server (ie the connection string changed). Even though the DAL's connection string was still unchanged, valid and the ASP.NET project wasn't involved when you want to "Update model from database" at design time, it must be something to do with the default project clashing with it.
I changed the connstring in the web config of the project containing the edmx to be the same as the default project's one, and it worked again.
If you happen to be bouncing between environments (e.g. dev, prod) when this problem popped up and you are running different SQL Server version (e.g. 2005, 2008) in those environments, you can have some problems. The DB version number gets stored somewhere in the .edmx file.
If that is the case, let me know and I can dig up the specifics and respond with them. If not, I don't know what it could be.
Good luck!
EDIT: I realize this probably has nothing to do with the actual problem, but I wanted to provide the specifics I mentioned in case someone else runs across this. The ProviderManifestToken attribute in the Schema element (inside the .edmx) contains the database version number. Note that it actually uses the year (e.g. 2005, 2008) instead of the true DB version number. If you create a model on one version and move it to another version, you'll need to manually edit the file to change this value.
<edmx:Edmx Version="2.0" xmlns:edmx="http://schemas.microsoft.com/ado/2008/10/edmx">
<!-- EF Runtime content -->
<edmx:Runtime>
<!-- SSDL content -->
<edmx:StorageModels>
<Schema Namespace="..." Alias="Self" Provider="System.Data.SqlClient" ProviderManifestToken="2005" xmlns:store="http://schemas.microsoft.com/ado/2007/12/edm/EntityStoreSchemaGenerator" xmlns="http://schemas.microsoft.com/ado/2009/02/edm/ssdl">
...
</Schema>
</edmx:StorageModels>
</edmx:Runtime>
</edmx:Edmx>
Old question but I thought I would post the fix that worked for me for those who still have this problem. In my case, it was simply a password issue. I was working in test, but the connection string was using the password for production. A more helpful response by VS might be to display an "Invalid login or password" type of message since that was actually the problem.

Resources