How to add a column to a database table using Subsonic? - c#

I am trying to add a column to a database table in an application that is using SubSonic 2.0.3.0 as the generator for the database layer.
I just cant get the hang of it. I tried to manually update the generated file of the table but it doesn't work. I have been trying to get the subsonic files regenerated but i cant find the sonic.exe tool that's needed? Can anyone help me to understand this?

You can download the latest 2.0 version of the project from https://github.com/subsonic/SubSonic-2.0, after you build it the sonic.exe will be in SubSonic\SubCommander\bin\Debug.
Then I've just got a little script file
del /q "DAL\*.*"
"..\..\ExternalResources\lib\sonic.exe" generate /out "DAL"
pause
Is that enough to get you on track?

Related

SQLite Error: Attempting To Write In A Read-Only Database

Im making a simple application in C# using Visual Studio and WinForms.. I’m using SQLite as my database.. When I use the Run feature within Visual Studio, everything works 100% beautifully.. The problem arises when I install my program onto another computer.
When I install and run my program in another computer, at first, everything works great. Things that require select statements work perfectly.. However, when I try to do something that adds a row to a table or modifies an existing row, my program crashes with the following error: “Attempting to write on a Read-Only Database.”
Upon doing some research online, I realized that this error wasn’t 100% accurate. The database is read-write.. However, the folder containing the database is read-only. So I guess I have to move my database from this read-only folder, to a read-write folder somehow.. How do I go about doing this? Which folder is it in currently, which folder should I move it to, and how do I prevent this move from causing any errors?
This answer identifies the problem, but doesn’t give a clear solution:
https://stackoverflow.com/a/16068894/10216226
Please help me out! I’m at the final stretch of developing this application and I really would love to have this completed!
Thanks!

How can I export an assembly file in SQL Server

I am currently migrating a SQL Server database where a co-worker once created this dll using C#, but now I am struggling with it, since I have no idea how I can export mentioned dll, have seen that I need to make a c# function, but I don't understand quite well what I have to do
Does someone have been in the same situation? Do you have any idea how can I achieve this? Thanks a lot I'd really appreciate if you can help me
In sql server management studio, you could right-click the database, choose Tasks->Generate Script. Then search for a line of code that starts with "CREATE ASSEMBLY" - part of that line will be a long string of numbers, which is the dll

Entity framework not creating .cs file for new table

I'm using Entity framework 5 with a database first approach. I created a new database table and updated my .edmx. The .cs file was not created for my Model.tt, as explained here this is a bug in VS 2012.
I followed the work arounds as explained in this thread and I eventually updated to VS2012.4. The .cs file is still not created for my new table, any idea why this is happening and how I can fix this?
Your Tables must have primary key to create .cs files.
I decided to delete my edmx file and create a new connection to the database, and this error:
Connection failed, your password expired
Needless to say, a lot of time could have been saved if entity framework at least warned me when updating my model from database that my password expired, instead of just 'Updating' as if nothing is wrong.
So I renewed my password and guess what, everything is working!
Are you using a source control system that could be setting the directory as read only ? I've seen that problem before where automated tools were not generating what they are supposed to be doing because of that.
If you are using source control, check out the whole directory, exit VS. Open it back again and try to generate again.
I've had this problem both with and without an .edmx file and both times the problem was the same. When you create and save a new table in SQL Server, EF can't see it until you click on Tables > Refresh in the Object Browser.
I had a similar problem and it turned out that my .context.tt file and my .tt file had the wrong .edmx file name in them for the inputFile string variable. I believe this occurred as a result of someone renaming the .edmx file at some point.

Prepare code to programmatically create SQLite database - exporting template

In Microsoft Visual Express is there a way to export the SQLite database I've created through the Express interface into a code format so I can have it generated on first install by my customers?
I'd like to take the easiest way to do this without having to manually prepare all the code structure.
I was unable to find any sort of export feature. Any advice?
This resource will help me execute the code once I have it prepared, but I've 12 tables and some of them should come pre-populated, so being able to have the batch code will help.
If it's just an SQLite database you could just publish the file with the rest of your program since it's a normal file without any dependencies.

How to overcome vs_needsnewmetadata error in Data Flow task?

I have an SSIS package that copies the data in a table from one SQL Server 2005 to another SQL Server 2005. I do this with a "Data Flow" task. In the package config file I expose the destination table name.
Problem is when I change the destination table name in the config file (via notepad) I get the following error "vs_needsnewmetadata". I think I understand the problem... the destination table column mapping is fixed when I first set up the package.
Question: what's the easiest way to do the above with an ssis package?
I've read online about setting up the metadata programmatically and all but I'd like to avoid this. Also I wrote a C# console app that does everything just fine... all tables etc are specified in the app.config ... but apparently this solution isn't good enough.
Have you set DelayValidation to False on the Data Source Destination properties? If not, try that.
Edit: Of course that should be DelayValidation to True, so it just goes ahead and tries rather than checking. Also, instead of altering your package in Notepad, why not put the table name in a variable, put the variable into an Expression on the destination, then expose the variable in a .DtsConfig configuration file? Then you can change that without danger.
Matching source destination column with case sensitive has done the work for me.
Like in my case SrNo_prod was column in dev and using it we developed the dtsx, while it is been created as SrNo_Prod in prod, after making case change from P to p, we got successful execution of package.
Check if the new destination table has the same columns as the old one.
I believe the error occurs if the columns are different, and the destination can no longer map its input columns to the table columns. If two tables have the same schema, this error should not occur.
If all you are doing is copying data from one SQL2005 server to another I would just create a Linked Server and use a stored proc to copy the data. An SSIS package is overkill.
How to Create linked server
Once the linked server is created you would just program something like...
INSERT INTO server1.dbo.database1.table1(id,name)
SELECT id, name FROM server2.dbo.database1.table1
As far the SSIS package I have always had to reopen and rebuild the package so that the meta data gets updated when modifying the tables column properties.

Categories

Resources