Visual Studio dropping 's' off of sql server tables - visual-studio-2010

When adding in tables from SQL Server to a dbml, it will drop the 's' off of the table name. One example: when adding the table 'Alias' it will change the name to 'Alia'. Is there any way to prevent this from happening?
Method of adding tables:
1) Connect to database in the Server Explorer Tab
2) Open tables folder
3) Select all the tables and drag them to the open dbml window

If you are using entity framework, and adding tables via the update wizard, there is a checkbox which says "Pluralize or singularize generated object names":
You can uncheck that and it will leave your table names alone.
Update: looks like you are drag/dropping to DBML, try this link:
Linq to SQL: How do I stop the auto generated object name from being renamed?

Related

Microsoft office cannot find the input table or query

I am trying to migrate an access database from 2000 to 20007 version. I have two .mdb files one used as a front end and the other containing only the back end tables. I performed all the necessary initialization for the migration like export of table, extension with .accd, etc.. But when i execute the following code , i get an error " Microsoft office cannot find the input table or query . Check spelling and so".
set Db=currentDb
SQLText ='some sql query'
Db.OpenRecordset(SQLText, dbOpenDynaset)
When i tried to output the value of Db with a msgbox (MSgbox Db), it shows the message "ABC, type mismatch", where ABC is the function name. But, Msgbox Db.name showing the correct database name. But, the same code has been running fine on the older version.
Please help me on this
Okay, you do not have to "migrate" to a different version persay. You only have to import everything from an MDB to ACCDB file. That is all. Scratch whatever you have done, start afresh.
Create a new "empty" accdb file, then using the options under
External Data-> Import/Link From Access. Select the Front End Access
file. Use the Option IMPORT Forms, Report etc., select all Forms, Reports, Queries, Mods then click OK. This
will import all objects.
Create a new "empty" accdb file, then using the options under
External Data-> Import/Link From Access. Select the Back End Access file. Use the Option IMPORT Forms, Report etc., select all tables and click OK. This will import all the tables over to the new file.
Now open up your new "front end" (the one with accdb extension). Under External Data -> Import/Link. Select the new "back end" (the one with the accdb extension). Use the Link to the Data Source option. Then select all tables and click OK.
Now perform a Compact & Repair, follow it with a Compile of the VBA code.
The whole strategy will fail if you have a backend DB in a different platform like SQL or Oracle.

Crystal Reports Data Source in Oracle

I inherited a legacy system using Crystal Reports in VS.NET pulling info from an Oracle11g DB.
The database fields are in "REPORT_DATA", I updated the stored procedure which the code is querying to add a field, however I cannot see that new field in the field explorer.
When I click on "Verify Database" and manage to log into the DB I get a "Remove Table" prompt - "The database table "REPORT_DATA" cannot be found. Proceed to remove this table from the report?"
Of course, there is no REPORT_DATA table and there never was.
When I preview the report or put it on the server it works, so there is some behind-the-scenes magic which I don't understand.
Figured it out.
I had to highlight the server name in the “Current Data Source” area and the name of the server in the “Replace With” area on the Set Datasource Location window. Then click the “Update” button.
Since the report wasn't built on my machine it had to be reconfigured - can't figure out why it still connected to the DB when previewing though.

Does not contain a definition...and no extension method

I am using linqpad4 with it's CRM 2011 plugin.
I get this error. How to fix it.
Does not contain a definition...and no extension method...
This error means something is changed in CRM schema, customization is published and you're trying to use new attribute in query but LinqPad schema is not updated.
Select the connection from left navigation, Right click and select Connection Properties. Ont he dialog bottom left Click on Refresh Schema. This will update the schema. Now you can work with latest schema.

Cannot create an ADO.NET entity data model through wizard

I have an issue and I cannot find out what the problem is. In visual studio 2010 I'm trying to add a new ADO.NET entity data model through the wizard (I'm using Entity Framework 4.1). After the second wizard step (that says "Choose your Data Connection") I press next and the wizard is closed right away, and there are no following steps at all. Here is my entity connection string:
metadata=res://*/DAL.Model1.csdl|res://*/DAL.Model1.ssdl|res://*/DAL.Model1.msl;provider=System.Data.SqlClient;provider connection string="Data Source=DMITRIY-TOSH\SQLEXPRESS;AttachDbFilename=|DataDirectory|\ASPNETDB.MDF;Integrated Security=True"
Is there anything wrong with that connection string? What should I change in it and how? Or what else can be the cause of the problem? Help me with this, please. I don't even know how to make it work to see the next wizard step where I can choose tables.
Found the solution. The folder "App_Data" (with the database inside) wasn't included into the project. Only because of that the wizard did not work.
I had this problem too, all the above didn't work for me. What helped for me was the following.
When you try to connect with a database that database can have different users with different credentials it can accept. Let's say user A till D.
If you try to connect with a user make sure that user has the right credentials enabled, in this case, read and write options enabled.
To do this start MS SQL Server Managment Studio, connected with your SQL server and select the database you try to make a connection with in visual studio. Under 'your_dbname' --> Security --> Users you find a list of users. Rightclick the username you try to login with and select properties. A window opens. Select the 'General' (selected by default) page and under tab 'Database role membership' make sure 'db_datareader' and 'db_datawrite' are selected.
Note: When you log in too MS SQL Server Managment Studio make sure you log in with a user which can enable/disable these options...
I created an empty model, then selected it in 'Model browser', right clicked on it and selected 'Update model from database'. Then I was able to add a table to it...

Remove schema from linq datacontexts (dbml)

When I add stored procedures to a linq datacontext, by default visual studio prefixes the stored procedure with the sql schema that it is in. Is there any way to stop this? In our environment, the stored procedures may be moved to other schemas over time, and we will default the schema based on the sql user used to connect. Do I have to do this manually or can I somehow turn off the schema prefixes?
There doesn't appear to be any means of removing the schema from LINQ-to-SQL mapped stored procedures using the designer. All procs are mapped including their schema name, which (to be fair) is probably a good thing for most applications. And as with most things LINQ-to-SQL, change your database at your own peril. Too many database changes required LINQ-to-SQL dbml updates & rebuilds.
Digging deeper, the schema name is stored in the backing dbml XML file, and is then included in the generated designer.cs file which contains the functions / methods which are called.
// dbml
<Function Name="dbo.MyProc" Method="MyProc">
// designer.cs
[global::System.Data.Linq.Mapping.FunctionAttribute(Name="dbo.MyProc")]
public int MyProc()
If you manually edit the dbml XML file to remove the schema & save within Visual Studio, the code will be regenerated like this:
// changed dbml - removed the dbo schema
<Function Name="MyProc" Method="MyProc">
// the resultant generated code in designer.cs
[global::System.Data.Linq.Mapping.FunctionAttribute()]
public int MyProc()
Which worked for my account, logging in with dbo as default schema. I'll leave the testing up to you.
This might be a workable solution - the visual designer still works like this, other items can be added etc without breaking the schema-less function, and the function itself doesn't cause the designer to complain. Best of luck!

Resources