C
C#2mo ago
hutoanhill

✅ using using to clear up ambiguous references.

I've to two method called index: Microsoft.EntityFrameworkCore.Index System.ComponentModel.DataAnnotations.Schema.Index i don't use the 2nd one. I want every mention of index to be interpreted as the first one. I've tried adding one of these using's to fix the problem, but nether works, it just says it Cannot resolve symbol 'Index'
using Index = Microsoft.EntityFrameworkCore.Index;
using IndexCB = System.ComponentModel.DataAnnotations.Schema.Index;
using Index = Microsoft.EntityFrameworkCore.Index;
using IndexCB = System.ComponentModel.DataAnnotations.Schema.Index;
25 Replies
jcotton42
jcotton422mo ago
Do you need anything from Schema?
Angius
Angius2mo ago
Alternatively: don't use data annotations and go with convention and fluent config
hutoanhill
hutoanhill2mo ago
yep if i dont use data annotations how do i get stuff like strings of limited length?
jcotton42
jcotton422mo ago
Wait, I don’t see an Index class in Schema in the docs.
Angius
Angius2mo ago
No description
hutoanhill
hutoanhill2mo ago
no idea what that is Got it! its IndexAttribute. not sure why is written different in the code...
jcotton42
jcotton422mo ago
You can omit the Attribute suffix when using attributes. Wait, is this EF or EF Core?
hutoanhill
hutoanhill2mo ago
Core?
jcotton42
jcotton422mo ago
Oh jesus it’s from EF6.
Angius
Angius2mo ago
Burn it
Angius
Angius2mo ago
Yeah well throw away this namespace
hutoanhill
hutoanhill2mo ago
i take it there is a better solution
Angius
Angius2mo ago
Yes, don't use anything from this namespace
jcotton42
jcotton422mo ago
Is this a new or existing app? I forget.
Angius
Angius2mo ago
Or use convention and fluent config
hutoanhill
hutoanhill2mo ago
in development
jcotton42
jcotton422mo ago
That particular Index attrib isn’t available if you’re using EF Core it seems. Show your csproj.
hutoanhill
hutoanhill2mo ago
and i am still firugint out how to use EF now that its set up. am willing to throw EF out in favor of a better solution
Angius
Angius2mo ago
FYI: EF and EF Core are two different things EF yuck ugly old yuck don't EF Core mmm pretty new mmm yes use
hutoanhill
hutoanhill2mo ago
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Discord.Net" Version="3.15.3"/>
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.8" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="8.0.8" />
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="8.0.8" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.8">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.8"/>
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.8">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="MySql.Data" Version="9.0.0"/>
<PackageReference Include="MySqlConnector" Version="2.3.7" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="Otp.NET" Version="1.4.0"/>
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="8.0.2"/>
<PackageReference Include="SQLite.Encryption.Extension" Version="1.0.118.1" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.7.3" />
<PackageReference Include="Swashbuckle.AspNetCore.Filters" Version="8.0.2"/>
<PackageReference Include="System.Data.SQLite" Version="1.0.118"/>
</ItemGroup>
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Discord.Net" Version="3.15.3"/>
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.8" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="8.0.8" />
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="8.0.8" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.8">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.8"/>
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.8">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="MySql.Data" Version="9.0.0"/>
<PackageReference Include="MySqlConnector" Version="2.3.7" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="Otp.NET" Version="1.4.0"/>
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="8.0.2"/>
<PackageReference Include="SQLite.Encryption.Extension" Version="1.0.118.1" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.7.3" />
<PackageReference Include="Swashbuckle.AspNetCore.Filters" Version="8.0.2"/>
<PackageReference Include="System.Data.SQLite" Version="1.0.118"/>
</ItemGroup>
<ItemGroup>
<Folder Include="Data\"/>
<Folder Include="Models\"/>
</ItemGroup>
</Project>
<ItemGroup>
<Folder Include="Data\"/>
<Folder Include="Models\"/>
</ItemGroup>
</Project>
jcotton42
jcotton422mo ago
Wait, that is EF Core. confused noises
hutoanhill
hutoanhill2mo ago
solved it with this: using Index = Microsoft.EntityFrameworkCore.IndexAttribute; so it is EF core
Angius
Angius2mo ago
Yeah, so just don't use the System.ComponentModel.DataAnnotations.Schema.Index namespace anywhere If you don't have a using with that, and you have using Microsoft.EntityFrameworkCore then only that one will be used
hutoanhill
hutoanhill2mo ago
thats what i am doing right now
Want results from more Discord servers?
Add your server