finding datatable that isnt under table's list in oracle sql developer - oracle-sqldeveloper

Im not sure how to explain this, but..
the program im working on in somehow recognizing a table named 'Transactions' and the table isnt found under the table's list in the database.
Im kinda lost on how to find it ..
then I saw that line:
private static readonly ILog logger = LogManager.GetLogger(typeof(Transactions));
and I was thinking maybe it reads the transactions from a log? if so, where do I find that log and how do both my program and oracle developer can pull data from that table.

Related

Oracle Data Modeler generated column name from datamodel too long

I'm trying to create a datamodel in the Oracle Data Modeler module that is available in Oracle SQL Developer. I would like to maintain my data dictionary from this model. To do this (I think) I need a generated DDL file for which the attributes are not longer than 30 characters.
I have just discovered Oracle SQL Developer and am completely new to creating these kind of models. What I have done so far. I have created a logical model and have engineered it to a relational model. From the relational model I can then generate DDL scripts that I can run on the database to make the changes I want.
When doing this I run into a problem. When engineering the logical model to a relational model I can see that the foreign keys I have made become more than 30 characters. This is because it seems to generate the name as (see picture)
From searching it seems you should be able to fix this with naming standard templates. I have looked for this menu option but can't find it. I have found the name abbreviations functionality for which you can upload .csv files but I think this is for something different.
Rightclicking on the logical model in the datamodeler browser view gives me the opportunity to Apply naming standards, but this gives me a message that I should turn off the keep as the name of the originating attribute option (see picture). I have looked for this but can't find this option.
My version of Oracle SQL Developer is 4.1.3.20, Build MAIN-20.78.
Please let me know if my story is not clear. Thanks.
Generated column name
Applying name standards message
You will find the option under Tools/Preferences/Data Modeler/Model/Logical

Trouble with Multi-Tenant Schema Generator Example

We are attempting to use CFE to generate one schema for each tenant as outlined in the CodeFluent blog post (http://blog.codefluententities.com/2014/12/04/multi-tenant-using-multiple-schema/). In this scenario, we are expecting that each schema generated should be identical and we are using the ICodeFluentPersistence Hook system to identify the company for a user and then properly set the schema to be used. All of that works fine, but when we run the code to generate the multiple schemas (https://github.com/SoftFluent/CodeFluent-Entities/tree/master/Extensions/SoftFluent.MultiTenantGenerator), it is removing the constraints. I then tried to see if there was an issue with my configuration, but running the sample program from GitHub produces the same results. After running the sample program, the Primary key was not present in the contoso schema, even though is was properly defined in the dbo schema (and in the model).
Has anyone used the CFE Multi-Schema generator or have any insight into what the issue may be?
Thanks for your response, but I am not sure that I agree. The whole reason (at least of me) to use the Multi-Tenant generator is to create as many database schemas as needed (one per client) from a single CFE model. The idea that you would lose the constraints in all but one of them didn't feel right so I did a bit more investigation and found the following in "Microsoft SQL Server 2012 Internals" by Kalen Delaney and Craig Freeman (through Google Books):
And in fact was able to do a quick test to prove this out by creating two identical tables with identical PK names:
So it would appear to me that CFE should be able to create the two identical databases from the same model and seems to point to a deficiency in the SQLServer diff engine.
The multi-schema generator loads the model and change it dynamically to modify the schema of the entities. Then it call the standard code production process with only the database producers (SQL Server, Oracle, etc.).
So if you want to generate 2 differents schema (dbo and contoso) against an empty database, the process is the following:
Generate the database for the dbo schema from a blank database
Generate the database for the contoso schema from the previously generated database
Before creating a constraint, the SQL Server diff engine drops the constraint with the same name. In fact SQL Server does not allow 2 constraints to have the same name (I can't find a page on MSDN with more details about that). So in your case the existing PK is dropped when you generate the contoso schema because the name of the PK is the same as the one that exists in the dbo schema. Maybe this can be improved, but the diffs engine tries to generate a code that works for SQL Server 2000 to SQL Server 2016.
Workarounds
You can generate each schema in a different database, so the diffs engine will generate the code you expect. Then you can run the generated scripts on the production database. Not the easiest way but it should work.
You can use the patch producer to replace the name of the schema in the file. For SQL files you should use the SqlServerPatchProducer as explain in the KnowledgeBase:
namespace Sample
{
public class SqlServerPatchProducer : SqlServerProducer
{
public SqlServerPatchProducer()
{
}
protected override void RunProceduresScript()
{
string path = GetPath(Project.DefaultNamespace + "_procedures.sql");
ProduceFrom(path, "before");
SearchAndReplaceProducer.ProducePatches(Project, null, this, null, ProductionFlags, Element);
Utilities.RunFileScript(path, Database, OutputEncoding);
ProduceFrom(path, "after");
}
}
}

EF Code first automatic migration totally messed up

I'm not sure what I've done, but I get this error when publishing to azure:
Automatic migration was not applied because it would result in data loss.
Now this is very distubing. My models match my database 100% - so is there a chance there might be data loss if I force it? I'm really confused what to do now.
So much for auto migrations :S Not much automation :)
I think my error was that I created new models, published it and EF created new tables for them. I then remembered that I forgot do add the models to my DbContext. So I added the new DbSets to context and published. That's probably where it went wrong. But then again, I didn't know that EF added models to the database if they aren't POCO classes or what ever they are called. Might have been some foreign keys that triggered.. dunno. Anyways I went undo frenzy on my code and deleted all the newly created tables and stuff to get me to my starting point. I thought that might solve it. But noooee stupid me.
Any ideas where to start on this issue? Im gonna jump off a cliff I lose my data :)
You can have EF create the SQL for you, so you can implement the migration manually. In the package manager console enter:
update-database -v -f -script
It will open a new window with the SQL that you can look over, and then apply yourself directly to the database. The last line that enters an entry into the migration history will allow the DbContext to know it's looking at the correct version.
First make a backup! Especially easy if you're using SQL Compact - just copy the file.
Or with LocalDB or SQL Server, Detach, copy file, Attach..
But to give a little more help, generating that script might still have you look for what might cause data loss. I find that adding a new column to become primary key in a table might loose data even if the original column is kept, because of a NOT NULL constraint being enforced on the new column causing (all) rows to be dropped.

Entity Framework and stored procedures with custom entities

I've got an existing EF4.1 project which is working just fine. I've added a new SP to the DB which returns a new kind of an entity (an existing entity with some additional fields).
The problem is when I try to import the function to the EF - it won't create my complex type. the wizard writes that "no database connection has been configured for this model". Which is strange - because it does see the new SP and everything.
I've tried creating my own, new complex type, but it won't map the fields as needed (some type conversion issues)
Any ideas what could be done?
Thanks!
To build on Malako's answer, I have a simlar situation. My problem was that my connection strings are in an external file
<connectionStrings configSource="some_other_file.config">
The "Update Models" wizard has a bug where it will not look in the external file for connection strings, and I cannot leave a connection string in the connectionStrings tag since it must be empty or it will give an error when building.
The workaround for me is to use the Update Wizard, check the box that says "Save entity connection string in Web.config", and then add all my function imports. When I'm done, I comment out the connectionString so my project will build. Next time, uncomment that entity connection string before updating models.
Annoying, but at least there's a way to get it to work.
For me, how I got it to work in my model project. There was other connection strings I left in there that had "server=" in there (non-EDMX related). I just deleted those other connection strings and the EDMX update wizard works as advertised.
Error message seen: Unable to update the App.Config file because of the following exception: 'The 'server' keyword is not supported.'
I assume the ConnectionString property of the entity model is empty. Check in model browser.
The easiest way to fix this is to remove all the connection strings in the .config files. Do a search for
connectionstring="
Delete the line(s) entirely or comment it/them with
Delete your edmx and recreate it. Make sure 'Save entity connection settings in Web.config as:' is checked.
Now the ConnectionString should be set and you will be able to generate complex models via function import.
if it still not works for you then remove other connection strings. and re add new.
the same problem is solved by this. removing all the connections string and added the Entity framework's connection string first then added the others but changed the name.
My solution to this same problem (VS2013) was this:
Go to Model Browser
Right click YourModel.edmx
Update Model from Database
Then it prompted me to select the connection. I selected the connection I wanted and proceeded to the next screen.
Add/Refresh/Delete what you need.
Select Finish and voila, the connection is here.
You have to add the connection string again every-time you add a stored procedure. Otherwise it will be no map when you try to get the columns you get a message on the "Edit Function import" you will See a message saying "No database connection has been configured for this model".
So my workaround is to re install the stored procedure again but what happens when I have 20 or more then every time I will have to re do all stored procedures. Or create a new model, this is the cons of this.
Here is the link of my solution there is a video and everything but I'm trying to figure How to do it with out deleting the model or adding the connection string VIDEO LINK OR stack overflow solution since there is not way yet to map store procedure I use a class my company has to retrieve has table from the store procedure and then send the data as JSON String if you want that solution let me know and then I will tray to do the code with the explanation (its done with a .dsn conection string and ODBC "Open Database Connectivity").

How to view generated SQL from Entity Framework?

As the title says, how do I view the SQL generated by Entity Framework from within my code? I'm running into an error where the EF is crashing because a field is generated by the database (a DateTime field), and I thought I set it to know that the store is generating it via StoreGeneratedPattern, but it's still crashing, so I would like to see what exactly it's trying to push up to the database.
P.S. I've only been using EF for about an hour now... Switching from L2S.
Since you don't have Sql Profiler, your best choice would be LINQPad. You can use your existing assembly.
Click Add connection -> Use a typed data context from your own assembly -> Entity framework and select your dll.
You can write queries directly against your model (or copy-paste from your code). Select the SQL 'tab' under the query window to view the generated SQL code.
You can use the Entity Framework Profiler (EFProf). It's not free, but there's a 30-day trial available. It does a lot more neat stuff besides showing you the SQL statements.
Generally, you should always use SQL Profiler to see the SQL statements that being submitted by EF into your database.
Also, I think you misunderstood about what StoreGeneratedPattern is. If you look at its possible values inside the model, you'll see that it has identity meaning that the value will be generated (by the database) when the row is inserted and will not otherwise change. The other options are Computed, which specifies that the value will be generated on inserts and updates, and None, which is the default.
So EF will not generate that DateTime field on the fly for you, you need to manually create it and then update your model from database so that EF will generate appropriate metadata to work with it at runtime.
The free AnjLab Sql Profiler will work if real SQL Profiler is not available because you're using SQL Server Express: http://anjlab.com/en/projects/opensource/sqlprofiler. It's not quite as nice as the real thing but it gets the job done well enough.
One solution would be to capture the network traffic and have a look at the data on that level. Microsoft Network Monitor does a good job of this.
Of course, that only works if you're using a separate DB server, and the connection is not encrypted.