Closed ghost closed 8 years ago
Hi there @swellfr ! Thanks for reporting the issue. Could you give me an example of how your using Bogus in LINQPad? If you provide an example that throws ArgumentException
, I can try to reproduce the issue on my side.
Thanks, Brian
To create the database I made it with EF CodeFirst.
Take a simple POCO
public class Person
{
public Guid Id {get; set;}
public string Name {get; set;}
}
Now in Linqpad create a query, select the database
and add the following code:
var personGenerator= new Faker<Person>()
.RuleFor(p => p.Name, f => f.Name.LastName());
var p = personGenerator.Generate();
If you try it, Linqpad will throw
Hi @swellfr , Thanks for the example.
I copy/pasted your example in LINQPad, the first error I got was:
CS0136 A local or parameter named 'p' cannot be declared
in this scope because that name is used in an enclosing local
scope to define a local or parameter
The problem was .RuleFor(p =>
conflicting with var p = personGenerator
. So I changed var p
to fakePerson
. See below:
Could you try my example in your LINQPad? If it runs, at least we know Bogus is working in LINQPad by itself. The problem could be further down the pipeline with EF.
If Bogus is working, could you give me an example EF query you're trying to use with Bogus that is probably throwing the exception?
The database is coming from ASP.NET Identity and it has been created with Code First.
Bogus throws only when you use Linqpad's ORM
Thanks @swellfr , I'm able to reproduce the error now. Your screenshot helps a lot. Give me a few to try to understand what's going on under the hood.
Ah, I see what's going on now. LINQPad, is generating AspNetUsers
table columns as fields, not properties. Bogus is expecting expressions of p => p.Property
, not p => p.Field
. I'll have this fixed soon.
Hi @swellfr , you should be good to go now.
Update Bogus and give 3.0.4 a try. Bogus now works on fields, not just properties. :+1:
Thanks again for reporting the issue.
Feel free to re-open the issue if you encounter any problems. Thx m8.
Brian
Works like a charm! :+1:
When I try to use bogus with linqpad ORM it throws this exception:
ArgumentException: Expression was not of the form 'x => x.property'.