« first day (2081 days earlier)      last day (2869 days later) » 

10:00 AM
Persons, Adress and Countries
actually
 
C4u
3 tables?
 
when you add a new person you also need to add a reference to the country table?
 
when I add a person, I add the person's adress
with a reference to a country, yes
 
ok wait Adresses is a separated table?
from persons
 
I select the country from the db, since it already exists
yea. because other entities have an address too
 
10:01 AM
did you normalized the DB?
you should end up with a junction table
 
between countries and people
 
Persons had a Adress_Id
 
or just reference the country ID in people table
 
Adress has a Country_Id
 
10:02 AM
ok
it should have XD
Country is 1 to many with persons right?
so just add the country ID as an FK to the persons table
 
C4u
Should be 1:n
 
country is 1 to many with Adress
got nothing to do with Person
 
not to address. whats the relation to people?
 
Person -> Adress -> Country
 
10:04 AM
I'm adding persons with their adress
and that duplicates countries for some reason
 
if the DB is normalized correctly such a problem shouldn't exist
 
and db.Entry(person.adress.country).state = EntityState.Unchanged

doesn't work
problem is I don't know how to normalize correctly...
 
C4u
Foreign keys and/or crosstables existing?
 
ok I will enumerate the thingies xD
 
10:05 AM
In my db I see teh foreign keys
 
1:n creates a foreign key in the n side
 
so the links seem to be working
 
many to many creates a new table with the two pk's being pk from each table
 
C4u
@LikeIfYouCaredAboutMyName Just if you do. Noone is treated by the database to set a FK ^^.
 
I know about db relations
 
10:06 AM
1:1 creates a new table with the two pks from th tables but
not being pk
 
I just don't know how anything about code first databases
 
I usually do model first
since I desing the DB first
but it's the same
*desaign
principle
 
C4u
Desaign :D
Funny you are..
 
**design
damn it XD
 
so


public class Adress
{
public int Id { get; set; }

[StringLength(50)]
public string Street { get; set; }

...other strings

public virtual Country Country { get; set; }
}
should be okay?
 
10:08 AM
yeah I think it's fine
can't you use model first?
 
C4u
@VictoriaS. What about posting show create table x;?
 
if you already have the DB
 
I'm going model first, or code first, I don't know what it's called anymore
 
model first it's when you create the classes from an existing DB
code first is the opposite
 
I'm trying to run a migration with a seed that pulls data from an old (and very badly made database)
 
10:10 AM
you create the classes and then it generates the tables
 
that.
I generate tables from classes
 
yes so it is code first
but as I said the principle is the same after you set up the tables
 
uhu
 
morning all
 
show the code where you're adding a new row
 
10:12 AM
hi
 
C4u
Hi
 
EF code first the topic this morning is it
oh yay
 
I think the problem is how you're inserting and not the DB design itself
but who knows, better as well cut down some possibilities
 
C4u
Maybe there are 2 inserts lol.
 
10:13 AM
using(DbContext db = new DbContext()){

DataTable dt = Get_Data("SELECT * FROM tbl_interimkantoor", curcon); //Old select method from old database

try
{
for (int i = 0; i < dt.Rows.Count; i++)
{
Person person = new Person();
...//person info
person.Adress = new Address(streetname,number,GetCountry(countryname))

db.Person.AddOrUpdate(person)
db.SaveChanges();

}
catch (Exception ex)
{
DataHelper.LogException(ex, "seed_InterimKantoren");
}
}
 
yeah who knows XD
 
ohshit. stupid enter
 
I don't see the line inserting
and saving changes
 
C4u
@LikeIfYouCaredAboutMyName Victoria said its duplicating the entris in Countries. If there would be only one insert into persons or addresses with an FK, how could it duplicate?
It couldnt I guess...
 
sorry, edited, I wasn't done typing
 
10:15 AM
@C4u hmmm I don't think that they pairs would duplicate either
 
I see what I see in my db, 25 'Belgium'
after the persons seed :/
 
I would most probably have a junction table
try just db.Person.Add
instead of addOrUpdate
 
C4u
@LikeIfYouCaredAboutMyName Dont get it.
 
Add did the same
I changed to AddOrUpdate to see if that would help
 
@C4u I said I was thinking in the same thing as you xD
 
C4u
10:17 AM
Ah alright.
 
@VictoriaS. can you show a diagram of the db?
something to understand better the desing
 
C4u
@VictoriaS. SHOW CREATE table x;
 
something weird is making that happen
 
I don't have a drawn out diagram, only code
 
do you have ON UPDATES, or something?
 
10:18 AM
no
not that I know of
 
but I don't think that would do that anyways
have you stepped through the code and verify if it's adding twice?
 
I have stepped trhough the code
and with every person I add
another country is added.
 
that's so weird
how the hell is it adding twice
some vudu XD
 
I don't know
 
C4u
SHOW CREATE table tableAdress;
SHOW CREATE table tablePerson;
SHOW CREATE table tableCountry;
On linux: tail -f yourSqlQueryLog
This you could do.
 
10:20 AM
I would think that the code was executing twice due to the for
 
@C4u I don't get what you're saying...
 
it's hard to guess without seeing how the DB is designed
what relations
and so on
 
also isn't naming tables table_SOmething
bad naming convention?
 
C4u
@VictoriaS. Da hell. Execute SHOW CREATE table yourTableName; in the database with your person, address and countries table.
It will output how the tables are designed.
 
sigh
 
10:21 AM
@VictoriaS. some say yes some don't. some just use tbl_something
but is kinda pointless
 
The relations are just what I said
1 Person has 1 Adres, 1 Adres has 1 Country
1 Country can belong to Multiple Adresses
 
well I will certainly stick with model first hahahah
 
I give up
 
nope don't do that
that's the 1st step to oblivious
you can do it
 
I've been stuck on this all day
 
10:23 AM
well I have been stuck correcting 1700+ errors manually for 3 days, you can do that
 
Stuck on that again? :P
 
yes, Roel
 
C4u
@LikeIfYouCaredAboutMyName LOL
 
it was fixed for like 10 minutes.
 
10:24 AM
@VictoriaS. have you got junction tables?
 
junction tables? for 1 to Many relations? No.
 
not for 1: 1 either
should i?
 
C4u
@VictoriaS. Just in case you thought Im designing like that: It was just to show-off what you have to replace.
 
create one between person and address, address country
@VictoriaS. well if normalized it would output two new tables for that, I like to do it that way to avoid confusion and helps with redundancy as well
 
10:26 AM
I don't think that will help...
besides it sounds so illogical :S
 
it's not illogical
xD
but well check your design again to see if everything matches up
if not I would suggest to go model first since you already know what tables you would have and so on
cause there's a weird situation there
and a redundancy problem as well I think
hence a design one
 
you just said there's no difference between model first and code first

besides I have to go code first, because I don't solidly know my tables.
 
@VictoriaS. I said the working principle is the same, but of course there's a difference
@VictoriaS. how sow? you already said you will have 3 tables and you most certainly know what will go on them right ?
 
yea
for those
but this project changes and grows every day
 
hmm I see
are you constantly adding new tables? o.O
 
10:30 AM
complain to my boss about that.
 
Get out a.s.a.p.
 
that's kind of a weird af principle
 
let's just say that now, I have to make views for Persons
Next week, Materials
Week after, Flubberlumpkins.
 
What's a flubberlumpkin?
 
We NEVER get the full picture.
@scheien everything.
 
10:32 AM
how does he want you to design a good DB if you get the info piece by piece?
that's stupid
 
@VictoriaS. Neat.
 
that's the thing
they want quantity, not quality
 
if you don't have the full panorama, things will most certainly go wrong
 
yea
which is WHY
I'm REMAKING old, broken software
 
you should remake your boss XDDD
 
10:33 AM
because everything here is dead code.
 
So you do what the majority of devs do? Refactor old junk?
or putting new stuff on top of old junk.
 
I'm trying to tell them this system doesn't work
but I get scolded at for that, that we need to work harder, faster
most of the team are putting new junk on top of old junk
 
ok I'm with roel get out asap
 
Would if I could
 
I don't understand those types of companies honestly
 
10:35 AM
If you are that frustrated, you should start looking for something new.
 
you want a good serious business if you incentivate people to make shit?
 
If I'd know this was how they worked... trust me I wouldn't be here
but now I feel like I have to fix things here.
 
@LikeIfYouCaredAboutMyName They recieve money you know. The customer doesn't always care about what's under the hood.
 
@scheien yeah but like, We got used to make things properly even if it took more time. because the customers wants things made ok not quick fix ups
well
go figure
 
I totally agree that's it's worthwhile to use some extra time up front, rather than bugfixing the next year(s).
 
10:37 AM
yea here it's all about quick fix
which is why everything is starting to fall apart
 
@VictoriaS. If you can't fix their mentality you can't fix anything. I wouldn't want to work in such an environment. I like places that make you thrive and make you grow up as a professional not those types of companies. But its most certainly not your fault
well I think that the problem is exactly the DB design but not from your side
do you have any way to see the rest of the design?
brb going to eat
 
I think I know what's causing it
I just don't know how to fix it
it's the
using(DbCOntext db = new DbContext(){

I think.
 
@VictoriaS. what's the problem?
so been in meetings and stuff
 
every piece of data is in another using
countries are in a using dbContext
persons are in a using dbCOntext
 
data / database activity?
I do mine by using ninject (IoC / DI) to inject the same DbContext
I have my Contexts per request
so a given API call if 6 different things go to the db they all use the same context
for the next call the same 6 things get a different context
 
10:48 AM
I have a couple functions
seedCountries();
seedPersons();

every function contains a using(dbCOntext)
I think that's why I get duplicates
 
Is seeding not done as part of your EF configuration class?
    public sealed class Configuration : DbMigrationsConfiguration<MyContext>
    {
        protected override void Seed(MyContext context)
        {

        }
    }
 
that's where I put those functions
 
call your functions from there and pass through the context
You shouldn't use a using in there though
 
I call functions from that seed
 
the caller that created that is responsible for cleaning it up
 
10:50 AM
I just tried what you said
 
protected override void Seed(MyContext context)
        {
              SeedCountries(context);
              SeedPeople(context);
        }
 
got the same error again
InvaliOperation
 
what you doing in the seed methods?
 
try
{
DataTable dt = Get_Data("SELECT * FROM tbl_landen", curcon);
for (int i = 0; i < dt.Rows.Count; i++)
{
Land tbl = new Land();
tbl.Naam = dt.Rows[i]["Land"].ToString();

db.Land.Add(tbl);
db.SaveChanges();
}
}
catch (Exception ex)
{
DataHelper.LogException(ex, "seed_landen");
}
 
10:52 AM
nope. Getting nowhere
that's just one example of what inside a seed function
(that i changed to work without using, that is)
 
SaveChanges in a loop is a bad idea
 
yeah
make it in the end
Add just adds in memory
 
is it?
I thought it caused outofmemoryexceptions at some point :X
 
SaveChanges is like the commit
 
YEA.
 
10:53 AM
hello
 
@VictoriaS. you should build a collection first
 
I got some images stored in db of like, 2 GB.
 
so add everything you want
verify the data if needes
and Save the changes in the end
 
how to check if propreties in this object is null?
var test = body.palett.GetType().GetProperties();
 
only SaveChanges once at the end of a transaction
 
10:54 AM
@Kob_24 null propagation?
 
verify?
 
@VictoriaS. do this ...
context.Countries.AddOrUpdate(someCollection)
1 call
 
also don't AddOrUpdate :D
 
I would refactor this
 
@VictoriaS. yes you can verify the data before commiting, but that's not for your problem now
 
10:54 AM
@StevenLiekens its seeding, you're supposed to
 
oh ok
 
@LikeIfYouCaredAboutMyName hmm never used it
 
ok.
 
protected override void Seed(MyContext context)
        {
              context.Countries.AddOrUpdate(GetCountries(context));
              context.People.AddOrUpdate(GetPeople(context));
        }
like that @VictoriaS.
 
Hey Fellas!
 
I just got a job offer for X++
 
just have the file reading code in the method
 
Long time no hear
 
I didn't even know what it was
 
@Kob_24 search it XD
!!google null propagation
 
10:56 AM
@StevenLiekens prototype language or something?
 
@LikeIfYouCaredAboutMyName i have a class with different propreties, i want to check whether each of them is null or not
 
@RoelvanUden @JakobMillah How are you doing guys? ^^
 
I don't think I would recommend X++ to anyone
 
the db.SaveChanges()
after ALL my seed fucntions? or in every seed function at the end?
 
10:57 AM
lol
 
@AdrianK. No work to do. I am currently sleeping at work. You?
 
I would SaveChanges only at the end
 
because I've got some annoyingly big data in my old db that needs to be transferred too
as in, 3 Gb per record
 
@Kob_24 you should only check when its necessary, like before disposing or before something that requires it, if so just access the property and check if it's null with an if statement
 
(don't ask me why they saved img data in the db)
 
10:58 AM
@VictoriaS. 3gb in record?
 
yes.
img data.
base64 strings even
 
you don't want to end up in a state where your migration only partially succeeded so you should really only save once at the very end
 
do i need to do this for all propreties!?
 
@JakobMillah I've just received my brand new PC for work. Lenovo P50.
 
@VictoriaS. 3GB? We have a database here where 1 table is about 300GB over a few weeks time
 
10:58 AM
@VictoriaS. at the end
 
Such speed. So performant. Wow.
 
after all the function calls not in any of them
 
ok.
 
@AdrianK. Yeah, dem feels with brand new pcs :P
 
what if I outofmemoryexception tho
 
10:59 AM
okay that is weird i must admit. Never heard/saw that
 
@JakobMillah and I haven't paid a dime for it :P
 
@JakobMillah you can't possibly imagine how bad their DB is, from what she described is the WW2 type of table, just chaos everywhere, screams and prayers that it will work
 

« first day (2081 days earlier)      last day (2869 days later) »