Visual Studio Object Relational Designer not generating classes for stored procedures - visual-studio-2010

This is my first project where I've needed to use Linq to SQL, so far I have generally found it easy to work with. However, when adding stored procedures in the o/r designer, it doesn't generate the classes and I have no idea why.
I've tried a simple stored proc that just selects from a table with no input parameters, but still no joy. I'm assuming I've overlooked a setting or something, but I can't find the solution. Can anyone help please?

Schoolboy error. I'd updated another table at the same time and hadn't noticed an error had crept in, so it wasn't updating anything never mind the stored procedures. Once the error was fixed the code regenerated and the stored procedures were available.

Related

ODAC/Entity Framework Model Update Issues

We are looking to introduce odac into our application but I am running into a number of issues and I can't seem to find any solutions that fix our issues.
We are using an oracle database and trying to use ODAC 12c Release 1 (12.1.0.1.0) with Oracle Developer Tools for Visual Studio.
In our model we would like to have multiple schemas so we can perform cross schema queries. The schemas which we select in the filter for the database connection appear when we are creating the model. However when we try to update our model from the database only the default schema is visible. Sometimes this can be fixed by opening the relevant part of the database in Server Explorer in Visual Studio but this doesn't always work. This fix never works after we add multiple connection strings for the same model (depending on the location of the user will depend on which database the user gets directed to).
The next issue we are having is that we can't the return types of stored procedures to be auto-generate. I have tried to retrieve the column information but it is never able to retrieve the metadata. I have seen a few suggestions of modifying the stored procedures then getting the column information and reverting the stored procedures but this is something we would like to avoid. Also the suggestions don't seem to work on oracle databases (but that could be me, I don't have much experience with databases).
The final issue (this is a minor issue) is that I cannot figure out how to get the generate code to omit underscores from the classes/methods generated. This isn't a huge issue it is purely to make it easier migrating the code we have.

VS 2010 database projects and tables created by "select into"

I am trying to move an existing database into a VS 2010 database project. This database has been around for a very long time and has a lot of stored procedures. Many of those stored procedures create working tables using the SELECT ... INTO syntax. This was done at the time to reduce the amount of data going through the transaction log. When I import the database into the project I deselected the work tables. Now when I look out the warning I see all of my stored procedures are saying that they can't find the work tables. Does anyone have a way of dealing with this? I am slowing converting as much as I can to SSIS but there is some logic that will have to remind in the stored procedures.
Thanks.
In this case you either have to ignore the warnings or import those working tables that are absolutely required for the stored procedures to work. I don't think the project will build properly if the tables are not present, but are expected.
If those tables are already present in the database, you should be fine as they won't be re-created. You can slowly deprecate them as you clean up your stored procedures.

Entity Framework writing to unknown database

I'm fairly new with EF and got myself rather confused about what's going on with my solution.
I'm in the situation where my code appears to be working however the changes aren't being written to the database that I would expect.
I'm using Web Developer 2010 and SQL 2008, code first approach but choosing to make my own changes in the database and manually ensure my classes match correctly.
Things seemed ok until I came across an error where the db hash wasn't what entity framework was expecting, so I looked at modelBuilder.Conventions.Remove(); which wasn't available - it seems that's not around in the later versions. So, I figured if the later versions doesn't do this check, I'll go ahead and remove my reference to EF 4 and put the 4.3 dll in it's place. I think I also ended up deleting and renaming my database. That didn't work, so I followed up on something I found on Scott Gu's blog about naming your dbContext the same as the database, which seemed to help.
However I'm now getting the most bizarre scenario. My code is running, the data is saving, but it's not saving to my database. In fact I'm running a profile trace on the db and it doesn't even seem to be trying to connect. I can change my connection string to something invalid too, but my code will happily run, storing the data #somewhere#
Any ideas what's going on? Might it be using a local database or cache that I'm unaware of? Should I just start my small project again and pretend this never happened? That'd be the professional approach, right?
I would suggest to use Database first approach, if you have your Database set, or want to have maximum control over database.

ASP.NET MVC 3, SQL Server; Code First EF approach not adding tables to App_Data/.mdf

When you use the Code First EF approach and just point to ./SQLEXPRESS, EF nicely builds your tables for you, defines all the fields, etc.
But it doesn't seem to work that way when you direct your connection string to add an .MDF file in /App_Data instead. Is that working as intended? The tutorials I'm finding on this, such as this one, show the tables in the .MDF being created by hand.
But I have not seen any documentation anywhere plainly state that Code First EF will build your tables one way but not the other, so I'm frankly just confused. Any illumination or advice on this would be greatly appreciated!
ETA: Okay, I see that this tutorial I linked is for the database-first approach, not code-first. In other places I'm reading that EF should, in theory, populate an App_Data/.mdf file the same way. But it still won't for me; if I give it an empty .mdf file to work with it refuses to add tables; if I don't give it an empty .mdf it tries to build one in my C:/Users/ directory.

Database project with a lot of references

I just try to set up a database project in Visual Studio 2010. We have one database, that contains a lot of stored procedures. Unfortunately those procedures accesses quite a lot of other databases (30+), so I get a lot of "unresolved references" errors.
At the moment I see two possibilities to solve my problem:
Add database projects to my solution, till I have all the errors resolved.
Create a lot of schemas for all my databases and add them as reference.
Both possibilities are a lot of work, especially as there can come a lot more databases in the future. My dream would be, that I can just add the whole server as a reference. Is that possible somehow? Are there any other solutions I don't know of?
This might help you. I found a article about referring databases here and this explains how to add multiple database project here
Hope this helps
This might not be the answer you are looking for, but you could setup one database to carry the references to the other databases via. "Server Objects -> Linked Servers" and change the code for the sp's to run through the 4 name quantifiers.
This would give you the added benefit of having the databases you depend on not hard coded.
Hope this is usefull to you.

Resources